muhammara 2.6.0 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -1
- package/node_modules/@mapbox/node-pre-gyp/CHANGELOG.md +3 -0
- package/node_modules/@mapbox/node-pre-gyp/README.md +1 -1
- package/node_modules/@mapbox/node-pre-gyp/package.json +5 -5
- package/node_modules/semver/classes/range.js +3 -0
- package/node_modules/semver/index.js +81 -41
- package/node_modules/semver/package.json +25 -14
- package/node_modules/tar/README.md +37 -9
- package/node_modules/tar/lib/create.js +16 -9
- package/node_modules/tar/lib/extract.js +16 -10
- package/node_modules/tar/lib/header.js +50 -34
- package/node_modules/tar/lib/large-numbers.js +22 -17
- package/node_modules/tar/lib/list.js +20 -13
- package/node_modules/tar/lib/mkdir.js +40 -24
- package/node_modules/tar/lib/mode-fix.js +8 -4
- package/node_modules/tar/lib/normalize-unicode.js +3 -2
- package/node_modules/tar/lib/pack.js +54 -31
- package/node_modules/tar/lib/parse.js +74 -46
- package/node_modules/tar/lib/path-reservations.js +26 -18
- package/node_modules/tar/lib/pax.js +15 -8
- package/node_modules/tar/lib/read-entry.js +14 -7
- package/node_modules/tar/lib/replace.js +50 -27
- package/node_modules/tar/lib/strip-absolute-path.js +1 -1
- package/node_modules/tar/lib/unpack.js +73 -44
- package/node_modules/tar/lib/update.js +8 -4
- package/node_modules/tar/lib/warn-mixin.js +7 -4
- package/node_modules/tar/lib/write-entry.js +44 -23
- package/node_modules/tar/package.json +44 -30
- package/package.json +1 -1
- package/src/deps/PDFWriter/CFFFileInput.cpp +7 -1
- package/src/deps/PDFWriter/DecryptionHelper.cpp +1 -1
- package/src/deps/PDFWriter/DocumentContext.cpp +21 -8
- package/src/deps/PDFWriter/DocumentContext.h +1 -1
- package/src/deps/PDFWriter/PDFModifiedPage.cpp +2 -0
- package/src/deps/PDFWriter/PDFPageInput.cpp +7 -1
- package/src/deps/PDFWriter/PDFParser.cpp +12 -0
- package/src/deps/PDFWriter/PDFUsedFont.cpp +4 -2
- package/src/deps/PDFWriter/TrueTypeEmbeddedFontWriter.cpp +15 -0
|
@@ -73,23 +73,27 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
73
73
|
this.readdirCache = opt.readdirCache || new Map()
|
|
74
74
|
|
|
75
75
|
this[WRITEENTRYCLASS] = WriteEntry
|
|
76
|
-
if (typeof opt.onwarn === 'function')
|
|
76
|
+
if (typeof opt.onwarn === 'function') {
|
|
77
77
|
this.on('warn', opt.onwarn)
|
|
78
|
+
}
|
|
78
79
|
|
|
79
80
|
this.portable = !!opt.portable
|
|
80
81
|
this.zip = null
|
|
81
82
|
if (opt.gzip) {
|
|
82
|
-
if (typeof opt.gzip !== 'object')
|
|
83
|
+
if (typeof opt.gzip !== 'object') {
|
|
83
84
|
opt.gzip = {}
|
|
84
|
-
|
|
85
|
+
}
|
|
86
|
+
if (this.portable) {
|
|
85
87
|
opt.gzip.portable = true
|
|
88
|
+
}
|
|
86
89
|
this.zip = new zlib.Gzip(opt.gzip)
|
|
87
90
|
this.zip.on('data', chunk => super.write(chunk))
|
|
88
91
|
this.zip.on('end', _ => super.end())
|
|
89
92
|
this.zip.on('drain', _ => this[ONDRAIN]())
|
|
90
93
|
this.on('resume', _ => this.zip.resume())
|
|
91
|
-
} else
|
|
94
|
+
} else {
|
|
92
95
|
this.on('drain', this[ONDRAIN])
|
|
96
|
+
}
|
|
93
97
|
|
|
94
98
|
this.noDirRecurse = !!opt.noDirRecurse
|
|
95
99
|
this.follow = !!opt.follow
|
|
@@ -115,30 +119,33 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
115
119
|
}
|
|
116
120
|
|
|
117
121
|
end (path) {
|
|
118
|
-
if (path)
|
|
122
|
+
if (path) {
|
|
119
123
|
this.write(path)
|
|
124
|
+
}
|
|
120
125
|
this[ENDED] = true
|
|
121
126
|
this[PROCESS]()
|
|
122
127
|
return this
|
|
123
128
|
}
|
|
124
129
|
|
|
125
130
|
write (path) {
|
|
126
|
-
if (this[ENDED])
|
|
131
|
+
if (this[ENDED]) {
|
|
127
132
|
throw new Error('write after end')
|
|
133
|
+
}
|
|
128
134
|
|
|
129
|
-
if (path instanceof ReadEntry)
|
|
135
|
+
if (path instanceof ReadEntry) {
|
|
130
136
|
this[ADDTARENTRY](path)
|
|
131
|
-
else
|
|
137
|
+
} else {
|
|
132
138
|
this[ADDFSENTRY](path)
|
|
139
|
+
}
|
|
133
140
|
return this.flowing
|
|
134
141
|
}
|
|
135
142
|
|
|
136
143
|
[ADDTARENTRY] (p) {
|
|
137
144
|
const absolute = normPath(path.resolve(this.cwd, p.path))
|
|
138
145
|
// in this case, we don't have to wait for the stat
|
|
139
|
-
if (!this.filter(p.path, p))
|
|
146
|
+
if (!this.filter(p.path, p)) {
|
|
140
147
|
p.resume()
|
|
141
|
-
else {
|
|
148
|
+
} else {
|
|
142
149
|
const job = new PackJob(p.path, absolute, false)
|
|
143
150
|
job.entry = new WriteEntryTar(p, this[ENTRYOPT](job))
|
|
144
151
|
job.entry.on('end', _ => this[JOBDONE](job))
|
|
@@ -162,10 +169,11 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
162
169
|
fs[stat](job.absolute, (er, stat) => {
|
|
163
170
|
job.pending = false
|
|
164
171
|
this[JOBS] -= 1
|
|
165
|
-
if (er)
|
|
172
|
+
if (er) {
|
|
166
173
|
this.emit('error', er)
|
|
167
|
-
else
|
|
174
|
+
} else {
|
|
168
175
|
this[ONSTAT](job, stat)
|
|
176
|
+
}
|
|
169
177
|
})
|
|
170
178
|
}
|
|
171
179
|
|
|
@@ -174,8 +182,9 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
174
182
|
job.stat = stat
|
|
175
183
|
|
|
176
184
|
// now we have the stat, we can filter it.
|
|
177
|
-
if (!this.filter(job.path, stat))
|
|
185
|
+
if (!this.filter(job.path, stat)) {
|
|
178
186
|
job.ignore = true
|
|
187
|
+
}
|
|
179
188
|
|
|
180
189
|
this[PROCESS]()
|
|
181
190
|
}
|
|
@@ -186,8 +195,9 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
186
195
|
fs.readdir(job.absolute, (er, entries) => {
|
|
187
196
|
job.pending = false
|
|
188
197
|
this[JOBS] -= 1
|
|
189
|
-
if (er)
|
|
198
|
+
if (er) {
|
|
190
199
|
return this.emit('error', er)
|
|
200
|
+
}
|
|
191
201
|
this[ONREADDIR](job, entries)
|
|
192
202
|
})
|
|
193
203
|
}
|
|
@@ -199,8 +209,9 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
199
209
|
}
|
|
200
210
|
|
|
201
211
|
[PROCESS] () {
|
|
202
|
-
if (this[PROCESSING])
|
|
212
|
+
if (this[PROCESSING]) {
|
|
203
213
|
return
|
|
214
|
+
}
|
|
204
215
|
|
|
205
216
|
this[PROCESSING] = true
|
|
206
217
|
for (let w = this[QUEUE].head;
|
|
@@ -217,9 +228,9 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
217
228
|
this[PROCESSING] = false
|
|
218
229
|
|
|
219
230
|
if (this[ENDED] && !this[QUEUE].length && this[JOBS] === 0) {
|
|
220
|
-
if (this.zip)
|
|
231
|
+
if (this.zip) {
|
|
221
232
|
this.zip.end(EOF)
|
|
222
|
-
else {
|
|
233
|
+
} else {
|
|
223
234
|
super.write(EOF)
|
|
224
235
|
super.end()
|
|
225
236
|
}
|
|
@@ -237,35 +248,42 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
237
248
|
}
|
|
238
249
|
|
|
239
250
|
[PROCESSJOB] (job) {
|
|
240
|
-
if (job.pending)
|
|
251
|
+
if (job.pending) {
|
|
241
252
|
return
|
|
253
|
+
}
|
|
242
254
|
|
|
243
255
|
if (job.entry) {
|
|
244
|
-
if (job === this[CURRENT] && !job.piped)
|
|
256
|
+
if (job === this[CURRENT] && !job.piped) {
|
|
245
257
|
this[PIPE](job)
|
|
258
|
+
}
|
|
246
259
|
return
|
|
247
260
|
}
|
|
248
261
|
|
|
249
262
|
if (!job.stat) {
|
|
250
|
-
if (this.statCache.has(job.absolute))
|
|
263
|
+
if (this.statCache.has(job.absolute)) {
|
|
251
264
|
this[ONSTAT](job, this.statCache.get(job.absolute))
|
|
252
|
-
else
|
|
265
|
+
} else {
|
|
253
266
|
this[STAT](job)
|
|
267
|
+
}
|
|
254
268
|
}
|
|
255
|
-
if (!job.stat)
|
|
269
|
+
if (!job.stat) {
|
|
256
270
|
return
|
|
271
|
+
}
|
|
257
272
|
|
|
258
273
|
// filtered out!
|
|
259
|
-
if (job.ignore)
|
|
274
|
+
if (job.ignore) {
|
|
260
275
|
return
|
|
276
|
+
}
|
|
261
277
|
|
|
262
278
|
if (!this.noDirRecurse && job.stat.isDirectory() && !job.readdir) {
|
|
263
|
-
if (this.readdirCache.has(job.absolute))
|
|
279
|
+
if (this.readdirCache.has(job.absolute)) {
|
|
264
280
|
this[ONREADDIR](job, this.readdirCache.get(job.absolute))
|
|
265
|
-
else
|
|
281
|
+
} else {
|
|
266
282
|
this[READDIR](job)
|
|
267
|
-
|
|
283
|
+
}
|
|
284
|
+
if (!job.readdir) {
|
|
268
285
|
return
|
|
286
|
+
}
|
|
269
287
|
}
|
|
270
288
|
|
|
271
289
|
// we know it doesn't have an entry, because that got checked above
|
|
@@ -275,8 +293,9 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
275
293
|
return
|
|
276
294
|
}
|
|
277
295
|
|
|
278
|
-
if (job === this[CURRENT] && !job.piped)
|
|
296
|
+
if (job === this[CURRENT] && !job.piped) {
|
|
279
297
|
this[PIPE](job)
|
|
298
|
+
}
|
|
280
299
|
}
|
|
281
300
|
|
|
282
301
|
[ENTRYOPT] (job) {
|
|
@@ -309,8 +328,9 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
309
328
|
}
|
|
310
329
|
|
|
311
330
|
[ONDRAIN] () {
|
|
312
|
-
if (this[CURRENT] && this[CURRENT].entry)
|
|
331
|
+
if (this[CURRENT] && this[CURRENT].entry) {
|
|
313
332
|
this[CURRENT].entry.resume()
|
|
333
|
+
}
|
|
314
334
|
}
|
|
315
335
|
|
|
316
336
|
// like .pipe() but using super, because our write() is special
|
|
@@ -330,20 +350,23 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
330
350
|
|
|
331
351
|
if (zip) {
|
|
332
352
|
source.on('data', chunk => {
|
|
333
|
-
if (!zip.write(chunk))
|
|
353
|
+
if (!zip.write(chunk)) {
|
|
334
354
|
source.pause()
|
|
355
|
+
}
|
|
335
356
|
})
|
|
336
357
|
} else {
|
|
337
358
|
source.on('data', chunk => {
|
|
338
|
-
if (!super.write(chunk))
|
|
359
|
+
if (!super.write(chunk)) {
|
|
339
360
|
source.pause()
|
|
361
|
+
}
|
|
340
362
|
})
|
|
341
363
|
}
|
|
342
364
|
}
|
|
343
365
|
|
|
344
366
|
pause () {
|
|
345
|
-
if (this.zip)
|
|
367
|
+
if (this.zip) {
|
|
346
368
|
this.zip.pause()
|
|
369
|
+
}
|
|
347
370
|
return super.pause()
|
|
348
371
|
}
|
|
349
372
|
})
|
|
@@ -28,6 +28,7 @@ const maxMetaEntrySize = 1024 * 1024
|
|
|
28
28
|
const Entry = require('./read-entry.js')
|
|
29
29
|
const Pax = require('./pax.js')
|
|
30
30
|
const zlib = require('minizlib')
|
|
31
|
+
const { nextTick } = require('process')
|
|
31
32
|
|
|
32
33
|
const gzipHeader = Buffer.from([0x1f, 0x8b])
|
|
33
34
|
const STATE = Symbol('state')
|
|
@@ -59,6 +60,7 @@ const DONE = Symbol('onDone')
|
|
|
59
60
|
const SAW_VALID_ENTRY = Symbol('sawValidEntry')
|
|
60
61
|
const SAW_NULL_BLOCK = Symbol('sawNullBlock')
|
|
61
62
|
const SAW_EOF = Symbol('sawEOF')
|
|
63
|
+
const CLOSESTREAM = Symbol('closeStream')
|
|
62
64
|
|
|
63
65
|
const noop = _ => true
|
|
64
66
|
|
|
@@ -82,14 +84,13 @@ module.exports = warner(class Parser extends EE {
|
|
|
82
84
|
}
|
|
83
85
|
})
|
|
84
86
|
|
|
85
|
-
if (opt.ondone)
|
|
87
|
+
if (opt.ondone) {
|
|
86
88
|
this.on(DONE, opt.ondone)
|
|
87
|
-
else {
|
|
89
|
+
} else {
|
|
88
90
|
this.on(DONE, _ => {
|
|
89
91
|
this.emit('prefinish')
|
|
90
92
|
this.emit('finish')
|
|
91
93
|
this.emit('end')
|
|
92
|
-
this.emit('close')
|
|
93
94
|
})
|
|
94
95
|
}
|
|
95
96
|
|
|
@@ -114,15 +115,21 @@ module.exports = warner(class Parser extends EE {
|
|
|
114
115
|
this[ABORTED] = false
|
|
115
116
|
this[SAW_NULL_BLOCK] = false
|
|
116
117
|
this[SAW_EOF] = false
|
|
117
|
-
|
|
118
|
+
|
|
119
|
+
this.on('end', () => this[CLOSESTREAM]())
|
|
120
|
+
|
|
121
|
+
if (typeof opt.onwarn === 'function') {
|
|
118
122
|
this.on('warn', opt.onwarn)
|
|
119
|
-
|
|
123
|
+
}
|
|
124
|
+
if (typeof opt.onentry === 'function') {
|
|
120
125
|
this.on('entry', opt.onentry)
|
|
126
|
+
}
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
[CONSUMEHEADER] (chunk, position) {
|
|
124
|
-
if (this[SAW_VALID_ENTRY] === null)
|
|
130
|
+
if (this[SAW_VALID_ENTRY] === null) {
|
|
125
131
|
this[SAW_VALID_ENTRY] = false
|
|
132
|
+
}
|
|
126
133
|
let header
|
|
127
134
|
try {
|
|
128
135
|
header = new Header(chunk, position, this[EX], this[GEX])
|
|
@@ -134,8 +141,9 @@ module.exports = warner(class Parser extends EE {
|
|
|
134
141
|
if (this[SAW_NULL_BLOCK]) {
|
|
135
142
|
this[SAW_EOF] = true
|
|
136
143
|
// ending an archive with no entries. pointless, but legal.
|
|
137
|
-
if (this[STATE] === 'begin')
|
|
144
|
+
if (this[STATE] === 'begin') {
|
|
138
145
|
this[STATE] = 'header'
|
|
146
|
+
}
|
|
139
147
|
this[EMIT]('eof')
|
|
140
148
|
} else {
|
|
141
149
|
this[SAW_NULL_BLOCK] = true
|
|
@@ -143,17 +151,17 @@ module.exports = warner(class Parser extends EE {
|
|
|
143
151
|
}
|
|
144
152
|
} else {
|
|
145
153
|
this[SAW_NULL_BLOCK] = false
|
|
146
|
-
if (!header.cksumValid)
|
|
147
|
-
this.warn('TAR_ENTRY_INVALID', 'checksum failure', {header})
|
|
148
|
-
else if (!header.path)
|
|
149
|
-
this.warn('TAR_ENTRY_INVALID', 'path is required', {header})
|
|
150
|
-
else {
|
|
154
|
+
if (!header.cksumValid) {
|
|
155
|
+
this.warn('TAR_ENTRY_INVALID', 'checksum failure', { header })
|
|
156
|
+
} else if (!header.path) {
|
|
157
|
+
this.warn('TAR_ENTRY_INVALID', 'path is required', { header })
|
|
158
|
+
} else {
|
|
151
159
|
const type = header.type
|
|
152
|
-
if (/^(Symbolic)?Link$/.test(type) && !header.linkpath)
|
|
153
|
-
this.warn('TAR_ENTRY_INVALID', 'linkpath required', {header})
|
|
154
|
-
else if (!/^(Symbolic)?Link$/.test(type) && header.linkpath)
|
|
155
|
-
this.warn('TAR_ENTRY_INVALID', 'linkpath forbidden', {header})
|
|
156
|
-
else {
|
|
160
|
+
if (/^(Symbolic)?Link$/.test(type) && !header.linkpath) {
|
|
161
|
+
this.warn('TAR_ENTRY_INVALID', 'linkpath required', { header })
|
|
162
|
+
} else if (!/^(Symbolic)?Link$/.test(type) && header.linkpath) {
|
|
163
|
+
this.warn('TAR_ENTRY_INVALID', 'linkpath forbidden', { header })
|
|
164
|
+
} else {
|
|
157
165
|
const entry = this[WRITEENTRY] = new Entry(header, this[EX], this[GEX])
|
|
158
166
|
|
|
159
167
|
// we do this for meta & ignored entries as well, because they
|
|
@@ -162,12 +170,14 @@ module.exports = warner(class Parser extends EE {
|
|
|
162
170
|
if (entry.remain) {
|
|
163
171
|
// this might be the one!
|
|
164
172
|
const onend = () => {
|
|
165
|
-
if (!entry.invalid)
|
|
173
|
+
if (!entry.invalid) {
|
|
166
174
|
this[SAW_VALID_ENTRY] = true
|
|
175
|
+
}
|
|
167
176
|
}
|
|
168
177
|
entry.on('end', onend)
|
|
169
|
-
} else
|
|
178
|
+
} else {
|
|
170
179
|
this[SAW_VALID_ENTRY] = true
|
|
180
|
+
}
|
|
171
181
|
}
|
|
172
182
|
|
|
173
183
|
if (entry.meta) {
|
|
@@ -191,9 +201,9 @@ module.exports = warner(class Parser extends EE {
|
|
|
191
201
|
this[STATE] = entry.remain ? 'ignore' : 'header'
|
|
192
202
|
entry.resume()
|
|
193
203
|
} else {
|
|
194
|
-
if (entry.remain)
|
|
204
|
+
if (entry.remain) {
|
|
195
205
|
this[STATE] = 'body'
|
|
196
|
-
else {
|
|
206
|
+
} else {
|
|
197
207
|
this[STATE] = 'header'
|
|
198
208
|
entry.end()
|
|
199
209
|
}
|
|
@@ -201,8 +211,9 @@ module.exports = warner(class Parser extends EE {
|
|
|
201
211
|
if (!this[READENTRY]) {
|
|
202
212
|
this[QUEUE].push(entry)
|
|
203
213
|
this[NEXTENTRY]()
|
|
204
|
-
} else
|
|
214
|
+
} else {
|
|
205
215
|
this[QUEUE].push(entry)
|
|
216
|
+
}
|
|
206
217
|
}
|
|
207
218
|
}
|
|
208
219
|
}
|
|
@@ -210,15 +221,19 @@ module.exports = warner(class Parser extends EE {
|
|
|
210
221
|
}
|
|
211
222
|
}
|
|
212
223
|
|
|
224
|
+
[CLOSESTREAM] () {
|
|
225
|
+
nextTick(() => this.emit('close'))
|
|
226
|
+
}
|
|
227
|
+
|
|
213
228
|
[PROCESSENTRY] (entry) {
|
|
214
229
|
let go = true
|
|
215
230
|
|
|
216
231
|
if (!entry) {
|
|
217
232
|
this[READENTRY] = null
|
|
218
233
|
go = false
|
|
219
|
-
} else if (Array.isArray(entry))
|
|
234
|
+
} else if (Array.isArray(entry)) {
|
|
220
235
|
this.emit.apply(this, entry)
|
|
221
|
-
else {
|
|
236
|
+
} else {
|
|
222
237
|
this[READENTRY] = entry
|
|
223
238
|
this.emit('entry', entry)
|
|
224
239
|
if (!entry.emittedEnd) {
|
|
@@ -244,10 +259,12 @@ module.exports = warner(class Parser extends EE {
|
|
|
244
259
|
const re = this[READENTRY]
|
|
245
260
|
const drainNow = !re || re.flowing || re.size === re.remain
|
|
246
261
|
if (drainNow) {
|
|
247
|
-
if (!this[WRITING])
|
|
262
|
+
if (!this[WRITING]) {
|
|
248
263
|
this.emit('drain')
|
|
249
|
-
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
250
266
|
re.once('drain', _ => this.emit('drain'))
|
|
267
|
+
}
|
|
251
268
|
}
|
|
252
269
|
}
|
|
253
270
|
|
|
@@ -274,17 +291,19 @@ module.exports = warner(class Parser extends EE {
|
|
|
274
291
|
const ret = this[CONSUMEBODY](chunk, position)
|
|
275
292
|
|
|
276
293
|
// if we finished, then the entry is reset
|
|
277
|
-
if (!this[WRITEENTRY])
|
|
294
|
+
if (!this[WRITEENTRY]) {
|
|
278
295
|
this[EMITMETA](entry)
|
|
296
|
+
}
|
|
279
297
|
|
|
280
298
|
return ret
|
|
281
299
|
}
|
|
282
300
|
|
|
283
301
|
[EMIT] (ev, data, extra) {
|
|
284
|
-
if (!this[QUEUE].length && !this[READENTRY])
|
|
302
|
+
if (!this[QUEUE].length && !this[READENTRY]) {
|
|
285
303
|
this.emit(ev, data, extra)
|
|
286
|
-
else
|
|
304
|
+
} else {
|
|
287
305
|
this[QUEUE].push([ev, data, extra])
|
|
306
|
+
}
|
|
288
307
|
}
|
|
289
308
|
|
|
290
309
|
[EMITMETA] (entry) {
|
|
@@ -323,8 +342,9 @@ module.exports = warner(class Parser extends EE {
|
|
|
323
342
|
}
|
|
324
343
|
|
|
325
344
|
write (chunk) {
|
|
326
|
-
if (this[ABORTED])
|
|
345
|
+
if (this[ABORTED]) {
|
|
327
346
|
return
|
|
347
|
+
}
|
|
328
348
|
|
|
329
349
|
// first write, might be gzipped
|
|
330
350
|
if (this[UNZIP] === null && chunk) {
|
|
@@ -337,8 +357,9 @@ module.exports = warner(class Parser extends EE {
|
|
|
337
357
|
return true
|
|
338
358
|
}
|
|
339
359
|
for (let i = 0; this[UNZIP] === null && i < gzipHeader.length; i++) {
|
|
340
|
-
if (chunk[i] !== gzipHeader[i])
|
|
360
|
+
if (chunk[i] !== gzipHeader[i]) {
|
|
341
361
|
this[UNZIP] = false
|
|
362
|
+
}
|
|
342
363
|
}
|
|
343
364
|
if (this[UNZIP] === null) {
|
|
344
365
|
const ended = this[ENDED]
|
|
@@ -358,10 +379,11 @@ module.exports = warner(class Parser extends EE {
|
|
|
358
379
|
}
|
|
359
380
|
|
|
360
381
|
this[WRITING] = true
|
|
361
|
-
if (this[UNZIP])
|
|
382
|
+
if (this[UNZIP]) {
|
|
362
383
|
this[UNZIP].write(chunk)
|
|
363
|
-
else
|
|
384
|
+
} else {
|
|
364
385
|
this[CONSUMECHUNK](chunk)
|
|
386
|
+
}
|
|
365
387
|
this[WRITING] = false
|
|
366
388
|
|
|
367
389
|
// return false if there's a queue, or if the current entry isn't flowing
|
|
@@ -371,15 +393,17 @@ module.exports = warner(class Parser extends EE {
|
|
|
371
393
|
true
|
|
372
394
|
|
|
373
395
|
// if we have no queue, then that means a clogged READENTRY
|
|
374
|
-
if (!ret && !this[QUEUE].length)
|
|
396
|
+
if (!ret && !this[QUEUE].length) {
|
|
375
397
|
this[READENTRY].once('drain', _ => this.emit('drain'))
|
|
398
|
+
}
|
|
376
399
|
|
|
377
400
|
return ret
|
|
378
401
|
}
|
|
379
402
|
|
|
380
403
|
[BUFFERCONCAT] (c) {
|
|
381
|
-
if (c && !this[ABORTED])
|
|
404
|
+
if (c && !this[ABORTED]) {
|
|
382
405
|
this[BUFFER] = this[BUFFER] ? Buffer.concat([this[BUFFER], c]) : c
|
|
406
|
+
}
|
|
383
407
|
}
|
|
384
408
|
|
|
385
409
|
[MAYBEEND] () {
|
|
@@ -393,9 +417,10 @@ module.exports = warner(class Parser extends EE {
|
|
|
393
417
|
// truncated, likely a damaged file
|
|
394
418
|
const have = this[BUFFER] ? this[BUFFER].length : 0
|
|
395
419
|
this.warn('TAR_BAD_ARCHIVE', `Truncated input (needed ${
|
|
396
|
-
entry.blockRemain} more bytes, only ${have} available)`, {entry})
|
|
397
|
-
if (this[BUFFER])
|
|
420
|
+
entry.blockRemain} more bytes, only ${have} available)`, { entry })
|
|
421
|
+
if (this[BUFFER]) {
|
|
398
422
|
entry.write(this[BUFFER])
|
|
423
|
+
}
|
|
399
424
|
entry.end()
|
|
400
425
|
}
|
|
401
426
|
this[EMIT](DONE)
|
|
@@ -403,19 +428,20 @@ module.exports = warner(class Parser extends EE {
|
|
|
403
428
|
}
|
|
404
429
|
|
|
405
430
|
[CONSUMECHUNK] (chunk) {
|
|
406
|
-
if (this[CONSUMING])
|
|
431
|
+
if (this[CONSUMING]) {
|
|
407
432
|
this[BUFFERCONCAT](chunk)
|
|
408
|
-
else if (!chunk && !this[BUFFER])
|
|
433
|
+
} else if (!chunk && !this[BUFFER]) {
|
|
409
434
|
this[MAYBEEND]()
|
|
410
|
-
else {
|
|
435
|
+
} else {
|
|
411
436
|
this[CONSUMING] = true
|
|
412
437
|
if (this[BUFFER]) {
|
|
413
438
|
this[BUFFERCONCAT](chunk)
|
|
414
439
|
const c = this[BUFFER]
|
|
415
440
|
this[BUFFER] = null
|
|
416
441
|
this[CONSUMECHUNKSUB](c)
|
|
417
|
-
} else
|
|
442
|
+
} else {
|
|
418
443
|
this[CONSUMECHUNKSUB](chunk)
|
|
444
|
+
}
|
|
419
445
|
|
|
420
446
|
while (this[BUFFER] &&
|
|
421
447
|
this[BUFFER].length >= 512 &&
|
|
@@ -428,8 +454,9 @@ module.exports = warner(class Parser extends EE {
|
|
|
428
454
|
this[CONSUMING] = false
|
|
429
455
|
}
|
|
430
456
|
|
|
431
|
-
if (!this[BUFFER] || this[ENDED])
|
|
457
|
+
if (!this[BUFFER] || this[ENDED]) {
|
|
432
458
|
this[MAYBEEND]()
|
|
459
|
+
}
|
|
433
460
|
}
|
|
434
461
|
|
|
435
462
|
[CONSUMECHUNKSUB] (chunk) {
|
|
@@ -461,18 +488,19 @@ module.exports = warner(class Parser extends EE {
|
|
|
461
488
|
}
|
|
462
489
|
|
|
463
490
|
if (position < length) {
|
|
464
|
-
if (this[BUFFER])
|
|
491
|
+
if (this[BUFFER]) {
|
|
465
492
|
this[BUFFER] = Buffer.concat([chunk.slice(position), this[BUFFER]])
|
|
466
|
-
else
|
|
493
|
+
} else {
|
|
467
494
|
this[BUFFER] = chunk.slice(position)
|
|
495
|
+
}
|
|
468
496
|
}
|
|
469
497
|
}
|
|
470
498
|
|
|
471
499
|
end (chunk) {
|
|
472
500
|
if (!this[ABORTED]) {
|
|
473
|
-
if (this[UNZIP])
|
|
501
|
+
if (this[UNZIP]) {
|
|
474
502
|
this[UNZIP].end(chunk)
|
|
475
|
-
else {
|
|
503
|
+
} else {
|
|
476
504
|
this[ENDED] = true
|
|
477
505
|
this.write(chunk)
|
|
478
506
|
}
|
|
@@ -27,8 +27,9 @@ module.exports = () => {
|
|
|
27
27
|
// '/a/b/c/d' -> ['/', '/a', '/a/b', '/a/b/c', '/a/b/c/d']
|
|
28
28
|
const getDirs = path => {
|
|
29
29
|
const dirs = path.split('/').slice(0, -1).reduce((set, path) => {
|
|
30
|
-
if (set.length)
|
|
30
|
+
if (set.length) {
|
|
31
31
|
path = join(set[set.length - 1], path)
|
|
32
|
+
}
|
|
32
33
|
set.push(path || '/')
|
|
33
34
|
return set
|
|
34
35
|
}, [])
|
|
@@ -43,8 +44,9 @@ module.exports = () => {
|
|
|
43
44
|
const getQueues = fn => {
|
|
44
45
|
const res = reservations.get(fn)
|
|
45
46
|
/* istanbul ignore if - unpossible */
|
|
46
|
-
if (!res)
|
|
47
|
+
if (!res) {
|
|
47
48
|
throw new Error('function does not have any path reservations')
|
|
49
|
+
}
|
|
48
50
|
return {
|
|
49
51
|
paths: res.paths.map(path => queues.get(path)),
|
|
50
52
|
dirs: [...res.dirs].map(path => queues.get(path)),
|
|
@@ -54,23 +56,25 @@ module.exports = () => {
|
|
|
54
56
|
// check if fn is first in line for all its paths, and is
|
|
55
57
|
// included in the first set for all its dir queues
|
|
56
58
|
const check = fn => {
|
|
57
|
-
const {paths, dirs} = getQueues(fn)
|
|
59
|
+
const { paths, dirs } = getQueues(fn)
|
|
58
60
|
return paths.every(q => q[0] === fn) &&
|
|
59
61
|
dirs.every(q => q[0] instanceof Set && q[0].has(fn))
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
// run the function if it's first in line and not already running
|
|
63
65
|
const run = fn => {
|
|
64
|
-
if (running.has(fn) || !check(fn))
|
|
66
|
+
if (running.has(fn) || !check(fn)) {
|
|
65
67
|
return false
|
|
68
|
+
}
|
|
66
69
|
running.add(fn)
|
|
67
70
|
fn(() => clear(fn))
|
|
68
71
|
return true
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
const clear = fn => {
|
|
72
|
-
if (!running.has(fn))
|
|
75
|
+
if (!running.has(fn)) {
|
|
73
76
|
return false
|
|
77
|
+
}
|
|
74
78
|
|
|
75
79
|
const { paths, dirs } = reservations.get(fn)
|
|
76
80
|
const next = new Set()
|
|
@@ -78,29 +82,31 @@ module.exports = () => {
|
|
|
78
82
|
paths.forEach(path => {
|
|
79
83
|
const q = queues.get(path)
|
|
80
84
|
assert.equal(q[0], fn)
|
|
81
|
-
if (q.length === 1)
|
|
85
|
+
if (q.length === 1) {
|
|
82
86
|
queues.delete(path)
|
|
83
|
-
else {
|
|
87
|
+
} else {
|
|
84
88
|
q.shift()
|
|
85
|
-
if (typeof q[0] === 'function')
|
|
89
|
+
if (typeof q[0] === 'function') {
|
|
86
90
|
next.add(q[0])
|
|
87
|
-
else
|
|
91
|
+
} else {
|
|
88
92
|
q[0].forEach(fn => next.add(fn))
|
|
93
|
+
}
|
|
89
94
|
}
|
|
90
95
|
})
|
|
91
96
|
|
|
92
97
|
dirs.forEach(dir => {
|
|
93
98
|
const q = queues.get(dir)
|
|
94
99
|
assert(q[0] instanceof Set)
|
|
95
|
-
if (q[0].size === 1 && q.length === 1)
|
|
100
|
+
if (q[0].size === 1 && q.length === 1) {
|
|
96
101
|
queues.delete(dir)
|
|
97
|
-
else if (q[0].size === 1) {
|
|
102
|
+
} else if (q[0].size === 1) {
|
|
98
103
|
q.shift()
|
|
99
104
|
|
|
100
105
|
// must be a function or else the Set would've been reused
|
|
101
106
|
next.add(q[0])
|
|
102
|
-
} else
|
|
107
|
+
} else {
|
|
103
108
|
q[0].delete(fn)
|
|
109
|
+
}
|
|
104
110
|
})
|
|
105
111
|
running.delete(fn)
|
|
106
112
|
|
|
@@ -123,22 +129,24 @@ module.exports = () => {
|
|
|
123
129
|
const dirs = new Set(
|
|
124
130
|
paths.map(path => getDirs(path)).reduce((a, b) => a.concat(b))
|
|
125
131
|
)
|
|
126
|
-
reservations.set(fn, {dirs, paths})
|
|
132
|
+
reservations.set(fn, { dirs, paths })
|
|
127
133
|
paths.forEach(path => {
|
|
128
134
|
const q = queues.get(path)
|
|
129
|
-
if (!q)
|
|
135
|
+
if (!q) {
|
|
130
136
|
queues.set(path, [fn])
|
|
131
|
-
else
|
|
137
|
+
} else {
|
|
132
138
|
q.push(fn)
|
|
139
|
+
}
|
|
133
140
|
})
|
|
134
141
|
dirs.forEach(dir => {
|
|
135
142
|
const q = queues.get(dir)
|
|
136
|
-
if (!q)
|
|
143
|
+
if (!q) {
|
|
137
144
|
queues.set(dir, [new Set([fn])])
|
|
138
|
-
else if (q[q.length - 1] instanceof Set)
|
|
145
|
+
} else if (q[q.length - 1] instanceof Set) {
|
|
139
146
|
q[q.length - 1].add(fn)
|
|
140
|
-
else
|
|
147
|
+
} else {
|
|
141
148
|
q.push(new Set([fn]))
|
|
149
|
+
}
|
|
142
150
|
})
|
|
143
151
|
|
|
144
152
|
return run(fn)
|