muhammara 3.2.0 → 3.3.0
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 +18 -1
- package/binding.gyp +2 -2
- package/muhammara.d.ts +1 -1
- 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/FreeType/binding.gyp +10 -0
- package/src/deps/LibAesgm/binding.gyp +10 -0
- package/src/deps/LibJpeg/binding.gyp +10 -0
- package/src/deps/LibPng/binding.gyp +11 -1
- package/src/deps/LibTiff/binding.gyp +10 -0
- package/src/deps/PDFWriter/binding.gyp +10 -0
- package/src/deps/ZLib/binding.gyp +10 -0
|
@@ -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)
|
|
@@ -24,8 +24,9 @@ class Pax {
|
|
|
24
24
|
|
|
25
25
|
encode () {
|
|
26
26
|
const body = this.encodeBody()
|
|
27
|
-
if (body === '')
|
|
27
|
+
if (body === '') {
|
|
28
28
|
return null
|
|
29
|
+
}
|
|
29
30
|
|
|
30
31
|
const bodyLen = Buffer.byteLength(body)
|
|
31
32
|
// round up to 512 bytes
|
|
@@ -34,8 +35,9 @@ class Pax {
|
|
|
34
35
|
const buf = Buffer.allocUnsafe(bufLen)
|
|
35
36
|
|
|
36
37
|
// 0-fill the header section, it might not hit every field
|
|
37
|
-
for (let i = 0; i < 512; i++)
|
|
38
|
+
for (let i = 0; i < 512; i++) {
|
|
38
39
|
buf[i] = 0
|
|
40
|
+
}
|
|
39
41
|
|
|
40
42
|
new Header({
|
|
41
43
|
// XXX split the path
|
|
@@ -60,8 +62,9 @@ class Pax {
|
|
|
60
62
|
buf.write(body, 512, bodyLen, 'utf8')
|
|
61
63
|
|
|
62
64
|
// null pad after the body
|
|
63
|
-
for (let i = bodyLen + 512; i < buf.length; i++)
|
|
65
|
+
for (let i = bodyLen + 512; i < buf.length; i++) {
|
|
64
66
|
buf[i] = 0
|
|
67
|
+
}
|
|
65
68
|
|
|
66
69
|
return buf
|
|
67
70
|
}
|
|
@@ -87,8 +90,9 @@ class Pax {
|
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
encodeField (field) {
|
|
90
|
-
if (this[field] === null || this[field] === undefined)
|
|
93
|
+
if (this[field] === null || this[field] === undefined) {
|
|
91
94
|
return ''
|
|
95
|
+
}
|
|
92
96
|
const v = this[field] instanceof Date ? this[field].getTime() / 1000
|
|
93
97
|
: this[field]
|
|
94
98
|
const s = ' ' +
|
|
@@ -100,8 +104,9 @@ class Pax {
|
|
|
100
104
|
// so if it's 9 characters, then adding 1 for the 9 makes it 10
|
|
101
105
|
// which makes it 11 chars.
|
|
102
106
|
let digits = Math.floor(Math.log(byteLen) / Math.log(10)) + 1
|
|
103
|
-
if (byteLen + digits >= Math.pow(10, digits))
|
|
107
|
+
if (byteLen + digits >= Math.pow(10, digits)) {
|
|
104
108
|
digits += 1
|
|
109
|
+
}
|
|
105
110
|
const len = digits + byteLen
|
|
106
111
|
return len + s
|
|
107
112
|
}
|
|
@@ -123,14 +128,16 @@ const parseKVLine = (set, line) => {
|
|
|
123
128
|
|
|
124
129
|
// XXX Values with \n in them will fail this.
|
|
125
130
|
// Refactor to not be a naive line-by-line parse.
|
|
126
|
-
if (n !== Buffer.byteLength(line) + 1)
|
|
131
|
+
if (n !== Buffer.byteLength(line) + 1) {
|
|
127
132
|
return set
|
|
133
|
+
}
|
|
128
134
|
|
|
129
|
-
line = line.
|
|
135
|
+
line = line.slice((n + ' ').length)
|
|
130
136
|
const kv = line.split('=')
|
|
131
137
|
const k = kv.shift().replace(/^SCHILY\.(dev|ino|nlink)/, '$1')
|
|
132
|
-
if (!k)
|
|
138
|
+
if (!k) {
|
|
133
139
|
return set
|
|
140
|
+
}
|
|
134
141
|
|
|
135
142
|
const v = kv.join('=')
|
|
136
143
|
set[k] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(k)
|
|
@@ -49,8 +49,9 @@ module.exports = class ReadEntry extends MiniPass {
|
|
|
49
49
|
|
|
50
50
|
this.path = normPath(header.path)
|
|
51
51
|
this.mode = header.mode
|
|
52
|
-
if (this.mode)
|
|
52
|
+
if (this.mode) {
|
|
53
53
|
this.mode = this.mode & 0o7777
|
|
54
|
+
}
|
|
54
55
|
this.uid = header.uid
|
|
55
56
|
this.gid = header.gid
|
|
56
57
|
this.uname = header.uname
|
|
@@ -63,26 +64,31 @@ module.exports = class ReadEntry extends MiniPass {
|
|
|
63
64
|
this.uname = header.uname
|
|
64
65
|
this.gname = header.gname
|
|
65
66
|
|
|
66
|
-
if (ex)
|
|
67
|
+
if (ex) {
|
|
67
68
|
this[SLURP](ex)
|
|
68
|
-
|
|
69
|
+
}
|
|
70
|
+
if (gex) {
|
|
69
71
|
this[SLURP](gex, true)
|
|
72
|
+
}
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
write (data) {
|
|
73
76
|
const writeLen = data.length
|
|
74
|
-
if (writeLen > this.blockRemain)
|
|
77
|
+
if (writeLen > this.blockRemain) {
|
|
75
78
|
throw new Error('writing more to entry than is appropriate')
|
|
79
|
+
}
|
|
76
80
|
|
|
77
81
|
const r = this.remain
|
|
78
82
|
const br = this.blockRemain
|
|
79
83
|
this.remain = Math.max(0, r - writeLen)
|
|
80
84
|
this.blockRemain = Math.max(0, br - writeLen)
|
|
81
|
-
if (this.ignore)
|
|
85
|
+
if (this.ignore) {
|
|
82
86
|
return true
|
|
87
|
+
}
|
|
83
88
|
|
|
84
|
-
if (r >= writeLen)
|
|
89
|
+
if (r >= writeLen) {
|
|
85
90
|
return super.write(data)
|
|
91
|
+
}
|
|
86
92
|
|
|
87
93
|
// r < writeLen
|
|
88
94
|
return super.write(data.slice(0, r))
|
|
@@ -93,8 +99,9 @@ module.exports = class ReadEntry extends MiniPass {
|
|
|
93
99
|
// we slurp in everything except for the path attribute in
|
|
94
100
|
// a global extended header, because that's weird.
|
|
95
101
|
if (ex[k] !== null && ex[k] !== undefined &&
|
|
96
|
-
!(global && k === 'path'))
|
|
102
|
+
!(global && k === 'path')) {
|
|
97
103
|
this[k] = k === 'path' || k === 'linkpath' ? normPath(ex[k]) : ex[k]
|
|
104
|
+
}
|
|
98
105
|
}
|
|
99
106
|
}
|
|
100
107
|
}
|