tar 4.4.1 → 4.4.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/lib/unpack.js +14 -2
- package/package.json +5 -5
package/lib/unpack.js
CHANGED
|
@@ -12,6 +12,7 @@ const wc = require('./winchars.js')
|
|
|
12
12
|
|
|
13
13
|
const ONENTRY = Symbol('onEntry')
|
|
14
14
|
const CHECKFS = Symbol('checkFs')
|
|
15
|
+
const ISREUSABLE = Symbol('isReusable')
|
|
15
16
|
const MAKEFS = Symbol('makeFs')
|
|
16
17
|
const FILE = Symbol('file')
|
|
17
18
|
const DIRECTORY = Symbol('directory')
|
|
@@ -351,6 +352,17 @@ class Unpack extends Parser {
|
|
|
351
352
|
entry.resume()
|
|
352
353
|
}
|
|
353
354
|
|
|
355
|
+
// Check if we can reuse an existing filesystem entry safely and
|
|
356
|
+
// overwrite it, rather than unlinking and recreating
|
|
357
|
+
// Windows doesn't report a useful nlink, so we just never reuse entries
|
|
358
|
+
[ISREUSABLE] (entry, st) {
|
|
359
|
+
return entry.type === 'File' &&
|
|
360
|
+
!this.unlink &&
|
|
361
|
+
st.isFile() &&
|
|
362
|
+
st.nlink <= 1 &&
|
|
363
|
+
process.platform !== 'win32'
|
|
364
|
+
}
|
|
365
|
+
|
|
354
366
|
// check if a thing is there, and if so, try to clobber it
|
|
355
367
|
[CHECKFS] (entry) {
|
|
356
368
|
this[PEND]()
|
|
@@ -360,7 +372,7 @@ class Unpack extends Parser {
|
|
|
360
372
|
fs.lstat(entry.absolute, (er, st) => {
|
|
361
373
|
if (st && (this.keep || this.newer && st.mtime > entry.mtime))
|
|
362
374
|
this[SKIP](entry)
|
|
363
|
-
else if (er || (entry
|
|
375
|
+
else if (er || this[ISREUSABLE](entry, st))
|
|
364
376
|
this[MAKEFS](null, entry)
|
|
365
377
|
else if (st.isDirectory()) {
|
|
366
378
|
if (entry.type === 'Directory') {
|
|
@@ -422,7 +434,7 @@ class UnpackSync extends Unpack {
|
|
|
422
434
|
const st = fs.lstatSync(entry.absolute)
|
|
423
435
|
if (this.keep || this.newer && st.mtime > entry.mtime)
|
|
424
436
|
return this[SKIP](entry)
|
|
425
|
-
else if (entry
|
|
437
|
+
else if (this[ISREUSABLE](entry, st))
|
|
426
438
|
return this[MAKEFS](null, entry)
|
|
427
439
|
else {
|
|
428
440
|
try {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
|
3
3
|
"name": "tar",
|
|
4
4
|
"description": "tar for node",
|
|
5
|
-
"version": "4.4.
|
|
5
|
+
"version": "4.4.2",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/npm/node-tar.git"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"minipass": "^2.2.4",
|
|
22
22
|
"minizlib": "^1.1.0",
|
|
23
23
|
"mkdirp": "^0.5.0",
|
|
24
|
-
"safe-buffer": "^5.1.
|
|
24
|
+
"safe-buffer": "^5.1.2",
|
|
25
25
|
"yallist": "^3.0.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"events-to-array": "^1.1.2",
|
|
31
31
|
"mutate-fs": "^2.1.1",
|
|
32
32
|
"rimraf": "^2.6.2",
|
|
33
|
-
"tap": "^11.1.
|
|
34
|
-
"tar-fs": "^1.16.
|
|
35
|
-
"tar-stream": "^1.
|
|
33
|
+
"tap": "^11.1.4",
|
|
34
|
+
"tar-fs": "^1.16.2",
|
|
35
|
+
"tar-stream": "^1.6.0"
|
|
36
36
|
},
|
|
37
37
|
"license": "ISC",
|
|
38
38
|
"engines": {
|