tar 5.0.0 → 5.0.5
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/README.md +21 -14
- package/lib/get-write-flag.js +20 -0
- package/lib/mode-fix.js +11 -1
- package/lib/pack.js +3 -1
- package/lib/unpack.js +3 -1
- package/lib/write-entry.js +2 -2
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -284,8 +284,9 @@ The following options are supported:
|
|
|
284
284
|
or `false` to omit it.
|
|
285
285
|
- `portable` Omit metadata that is system-specific: `ctime`, `atime`,
|
|
286
286
|
`uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and `nlink`. Note
|
|
287
|
-
that `mtime` is still included, because this is necessary other
|
|
288
|
-
time-based operations.
|
|
287
|
+
that `mtime` is still included, because this is necessary for other
|
|
288
|
+
time-based operations. Additionally, `mode` is set to a "reasonable
|
|
289
|
+
default" for most unix systems, based on a `umask` value of `0o22`.
|
|
289
290
|
- `preservePaths` Allow absolute paths. By default, `/` is stripped
|
|
290
291
|
from absolute paths. [Alias: `P`]
|
|
291
292
|
- `mode` The mode to set on the created file archive
|
|
@@ -484,8 +485,9 @@ The following options are supported:
|
|
|
484
485
|
or `false` to omit it.
|
|
485
486
|
- `portable` Omit metadata that is system-specific: `ctime`, `atime`,
|
|
486
487
|
`uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and `nlink`. Note
|
|
487
|
-
that `mtime` is still included, because this is necessary other
|
|
488
|
-
time-based operations.
|
|
488
|
+
that `mtime` is still included, because this is necessary for other
|
|
489
|
+
time-based operations. Additionally, `mode` is set to a "reasonable
|
|
490
|
+
default" for most unix systems, based on a `umask` value of `0o22`.
|
|
489
491
|
- `preservePaths` Allow absolute paths. By default, `/` is stripped
|
|
490
492
|
from absolute paths. [Alias: `P`]
|
|
491
493
|
- `maxReadSize` The maximum buffer size for `fs.read()` operations.
|
|
@@ -535,8 +537,9 @@ The following options are supported:
|
|
|
535
537
|
or `false` to omit it.
|
|
536
538
|
- `portable` Omit metadata that is system-specific: `ctime`, `atime`,
|
|
537
539
|
`uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and `nlink`. Note
|
|
538
|
-
that `mtime` is still included, because this is necessary other
|
|
539
|
-
time-based operations.
|
|
540
|
+
that `mtime` is still included, because this is necessary for other
|
|
541
|
+
time-based operations. Additionally, `mode` is set to a "reasonable
|
|
542
|
+
default" for most unix systems, based on a `umask` value of `0o22`.
|
|
540
543
|
- `preservePaths` Allow absolute paths. By default, `/` is stripped
|
|
541
544
|
from absolute paths. [Alias: `P`]
|
|
542
545
|
- `maxReadSize` The maximum buffer size for `fs.read()` operations.
|
|
@@ -582,8 +585,9 @@ The following options are supported:
|
|
|
582
585
|
or `false` to omit it.
|
|
583
586
|
- `portable` Omit metadata that is system-specific: `ctime`, `atime`,
|
|
584
587
|
`uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and `nlink`. Note
|
|
585
|
-
that `mtime` is still included, because this is necessary other
|
|
586
|
-
time-based operations.
|
|
588
|
+
that `mtime` is still included, because this is necessary for other
|
|
589
|
+
time-based operations. Additionally, `mode` is set to a "reasonable
|
|
590
|
+
default" for most unix systems, based on a `umask` value of `0o22`.
|
|
587
591
|
- `preservePaths` Allow absolute paths. By default, `/` is stripped
|
|
588
592
|
from absolute paths.
|
|
589
593
|
- `linkCache` A Map object containing the device and inode value for
|
|
@@ -795,8 +799,9 @@ It has the following fields:
|
|
|
795
799
|
object.
|
|
796
800
|
- `portable` Omit metadata that is system-specific: `ctime`, `atime`,
|
|
797
801
|
`uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and `nlink`. Note
|
|
798
|
-
that `mtime` is still included, because this is necessary other
|
|
799
|
-
time-based operations.
|
|
802
|
+
that `mtime` is still included, because this is necessary for other
|
|
803
|
+
time-based operations. Additionally, `mode` is set to a "reasonable
|
|
804
|
+
default" for most unix systems, based on a `umask` value of `0o22`.
|
|
800
805
|
- `myuid` If supported, the uid of the user running the current
|
|
801
806
|
process.
|
|
802
807
|
- `myuser` The `env.USER` string if set, or `''`. Set as the entry
|
|
@@ -834,8 +839,9 @@ The following options are supported:
|
|
|
834
839
|
|
|
835
840
|
- `portable` Omit metadata that is system-specific: `ctime`, `atime`,
|
|
836
841
|
`uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and `nlink`. Note
|
|
837
|
-
that `mtime` is still included, because this is necessary other
|
|
838
|
-
time-based operations.
|
|
842
|
+
that `mtime` is still included, because this is necessary for other
|
|
843
|
+
time-based operations. Additionally, `mode` is set to a "reasonable
|
|
844
|
+
default" for most unix systems, based on a `umask` value of `0o22`.
|
|
839
845
|
- `maxReadSize` The maximum buffer size for `fs.read()` operations.
|
|
840
846
|
Defaults to 1 MB.
|
|
841
847
|
- `linkCache` A Map object containing the device and inode value for
|
|
@@ -883,8 +889,9 @@ The following options are supported:
|
|
|
883
889
|
|
|
884
890
|
- `portable` Omit metadata that is system-specific: `ctime`, `atime`,
|
|
885
891
|
`uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and `nlink`. Note
|
|
886
|
-
that `mtime` is still included, because this is necessary other
|
|
887
|
-
time-based operations.
|
|
892
|
+
that `mtime` is still included, because this is necessary for other
|
|
893
|
+
time-based operations. Additionally, `mode` is set to a "reasonable
|
|
894
|
+
default" for most unix systems, based on a `umask` value of `0o22`.
|
|
888
895
|
- `preservePaths` Allow absolute paths. By default, `/` is stripped
|
|
889
896
|
from absolute paths.
|
|
890
897
|
- `strict` Treat warnings as crash-worthy errors. Default false.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Get the appropriate flag to use for creating files
|
|
2
|
+
// We use fmap on Windows platforms for files less than
|
|
3
|
+
// 512kb. This is a fairly low limit, but avoids making
|
|
4
|
+
// things slower in some cases. Since most of what this
|
|
5
|
+
// library is used for is extracting tarballs of many
|
|
6
|
+
// relatively small files in npm packages and the like,
|
|
7
|
+
// it can be a big boost on Windows platforms.
|
|
8
|
+
// Only supported in Node v12.9.0 and above.
|
|
9
|
+
const platform = process.env.__FAKE_PLATFORM__ || process.platform
|
|
10
|
+
const isWindows = platform === 'win32'
|
|
11
|
+
const fs = global.__FAKE_TESTING_FS__ || require('fs')
|
|
12
|
+
|
|
13
|
+
/* istanbul ignore next */
|
|
14
|
+
const { O_CREAT, O_TRUNC, O_WRONLY, UV_FS_O_FILEMAP = 0 } = fs.constants
|
|
15
|
+
|
|
16
|
+
const fMapEnabled = isWindows && !!UV_FS_O_FILEMAP
|
|
17
|
+
const fMapLimit = 512 * 1024
|
|
18
|
+
const fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY
|
|
19
|
+
module.exports = !fMapEnabled ? () => 'w'
|
|
20
|
+
: size => size < fMapLimit ? fMapFlag : 'w'
|
package/lib/mode-fix.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
module.exports = (mode, isDir) => {
|
|
2
|
+
module.exports = (mode, isDir, portable) => {
|
|
3
3
|
mode &= 0o7777
|
|
4
|
+
|
|
5
|
+
// in portable mode, use the minimum reasonable umask
|
|
6
|
+
// if this system creates files with 0o664 by default
|
|
7
|
+
// (as some linux distros do), then we'll write the
|
|
8
|
+
// archive with 0o644 instead. Also, don't ever create
|
|
9
|
+
// a file that is not readable/writable by the owner.
|
|
10
|
+
if (portable) {
|
|
11
|
+
mode = (mode | 0o600) &~0o22
|
|
12
|
+
}
|
|
13
|
+
|
|
4
14
|
// if dirs are readable, then they should be listable
|
|
5
15
|
if (isDir) {
|
|
6
16
|
if (mode & 0o400)
|
package/lib/pack.js
CHANGED
|
@@ -75,10 +75,13 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
75
75
|
if (typeof opt.onwarn === 'function')
|
|
76
76
|
this.on('warn', opt.onwarn)
|
|
77
77
|
|
|
78
|
+
this.portable = !!opt.portable
|
|
78
79
|
this.zip = null
|
|
79
80
|
if (opt.gzip) {
|
|
80
81
|
if (typeof opt.gzip !== 'object')
|
|
81
82
|
opt.gzip = {}
|
|
83
|
+
if (this.portable)
|
|
84
|
+
opt.gzip.portable = true
|
|
82
85
|
this.zip = new zlib.Gzip(opt.gzip)
|
|
83
86
|
this.zip.on('data', chunk => super.write(chunk))
|
|
84
87
|
this.zip.on('end', _ => super.end())
|
|
@@ -87,7 +90,6 @@ const Pack = warner(class Pack extends MiniPass {
|
|
|
87
90
|
} else
|
|
88
91
|
this.on('drain', this[ONDRAIN])
|
|
89
92
|
|
|
90
|
-
this.portable = !!opt.portable
|
|
91
93
|
this.noDirRecurse = !!opt.noDirRecurse
|
|
92
94
|
this.follow = !!opt.follow
|
|
93
95
|
this.noMtime = !!opt.noMtime
|
package/lib/unpack.js
CHANGED
|
@@ -42,6 +42,7 @@ const DOCHOWN = Symbol('doChown')
|
|
|
42
42
|
const UID = Symbol('uid')
|
|
43
43
|
const GID = Symbol('gid')
|
|
44
44
|
const crypto = require('crypto')
|
|
45
|
+
const getFlag = require('./get-write-flag.js')
|
|
45
46
|
|
|
46
47
|
/* istanbul ignore next */
|
|
47
48
|
const neverCalled = () => {
|
|
@@ -325,6 +326,7 @@ class Unpack extends Parser {
|
|
|
325
326
|
[FILE] (entry, fullyDone) {
|
|
326
327
|
const mode = entry.mode & 0o7777 || this.fmode
|
|
327
328
|
const stream = new fsm.WriteStream(entry.absolute, {
|
|
329
|
+
flags: getFlag(entry.size),
|
|
328
330
|
mode: mode,
|
|
329
331
|
autoClose: false
|
|
330
332
|
})
|
|
@@ -572,7 +574,7 @@ class UnpackSync extends Unpack {
|
|
|
572
574
|
let stream
|
|
573
575
|
let fd
|
|
574
576
|
try {
|
|
575
|
-
fd = fs.openSync(entry.absolute,
|
|
577
|
+
fd = fs.openSync(entry.absolute, getFlag(entry.size), mode)
|
|
576
578
|
} catch (er) {
|
|
577
579
|
return oner(er)
|
|
578
580
|
}
|
package/lib/write-entry.js
CHANGED
|
@@ -115,7 +115,7 @@ const WriteEntry = warner(class WriteEntry extends MiniPass {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
[MODE] (mode) {
|
|
118
|
-
return modeFix(mode, this.type === 'Directory')
|
|
118
|
+
return modeFix(mode, this.type === 'Directory', this.portable)
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
[HEADER] () {
|
|
@@ -406,7 +406,7 @@ const WriteEntryTar = warner(class WriteEntryTar extends MiniPass {
|
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
[MODE] (mode) {
|
|
409
|
-
return modeFix(mode, this.type === 'Directory')
|
|
409
|
+
return modeFix(mode, this.type === 'Directory', this.portable)
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
write (data) {
|
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": "5.0.
|
|
5
|
+
"version": "5.0.5",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/npm/node-tar.git"
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"chownr": "^1.1.3",
|
|
20
|
-
"fs-minipass": "^
|
|
21
|
-
"minipass": "^
|
|
22
|
-
"minizlib": "^1.
|
|
20
|
+
"fs-minipass": "^2.0.0",
|
|
21
|
+
"minipass": "^3.0.0",
|
|
22
|
+
"minizlib": "^2.1.0",
|
|
23
23
|
"mkdirp": "^0.5.0",
|
|
24
|
-
"yallist": "^
|
|
24
|
+
"yallist": "^4.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"chmodr": "^1.2.0",
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
"events-to-array": "^1.1.2",
|
|
30
30
|
"mutate-fs": "^2.1.1",
|
|
31
31
|
"rimraf": "^2.7.1",
|
|
32
|
-
"tap": "^14.6.
|
|
32
|
+
"tap": "^14.6.9",
|
|
33
33
|
"tar-fs": "^1.16.3",
|
|
34
34
|
"tar-stream": "^1.6.2"
|
|
35
35
|
},
|
|
36
36
|
"license": "ISC",
|
|
37
37
|
"engines": {
|
|
38
|
-
"node": ">=8"
|
|
38
|
+
"node": ">= 8"
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
41
|
"index.js",
|
|
42
|
-
"lib
|
|
42
|
+
"lib/*.js"
|
|
43
43
|
],
|
|
44
44
|
"tap": {
|
|
45
45
|
"coverage-map": "map.js",
|