@unbrained/pm-cli 2026.12.1 → 2026.12.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/.claude-plugin/marketplace.json +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-CWPR234D.js → chunk-7NAO7I75.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4YQMQOUO.js → chunk-7V65VACG.js} +52 -52
- package/dist/cli-bundle/chunks/{chunk-NA6D75V5.js → chunk-G6TARHFK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YSVOXCYH.js → chunk-GOEQXVOI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OKEJ4U2I.js → chunk-ROTEELDL.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-U7RBJGLF.js → chunk-SDXCJZKB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XME6GIFQ.js → chunk-TKUG2X24.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q6GLSAJY.js → chunk-UNBW2LF3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-V2S4XAX3.js +2 -0
- package/dist/cli-bundle/chunks/{item-transaction-66RDV7PH.js → item-transaction-56J5OCHA.js} +2 -2
- package/dist/cli-bundle/chunks/{linked-resource-value-list-E2DX52LY.js → linked-resource-value-list-ZBIY4H23.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-2F6JUBST.js → register-mutation-EK6DVIQK.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-ET3UKPYK.js → register-operations-6MURXE4V.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-I63QTFCU.js → register-setup-RW26X3GJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SQ72CVUH.js → chunk-3COWDIPX.js} +54 -54
- package/dist/cli-bundle/focused-chunks/{chunk-PT7RT3T6.js → chunk-J72TRWR5.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{item-transaction-2K4SFLJ7.js → item-transaction-LQLQLZE7.js} +2 -2
- package/dist/cli-bundle/main.js +3 -3
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +1 -1
- package/dist/sdk/extension/install-sources.d.ts +2 -2
- package/dist/sdk/extension/install-sources.js +5 -5
- package/marketplace.json +1 -1
- package/node_modules/tar/README.md +1792 -1147
- package/node_modules/tar/dist/commonjs/bytes.d.ts +21 -0
- package/node_modules/tar/dist/commonjs/bytes.js +83 -0
- package/node_modules/tar/dist/commonjs/codec.d.ts +53 -0
- package/node_modules/tar/dist/commonjs/codec.js +35 -0
- package/node_modules/tar/dist/commonjs/concat.d.ts +3 -0
- package/node_modules/tar/dist/commonjs/concat.js +20 -0
- package/node_modules/tar/dist/commonjs/create.d.ts +39 -2
- package/node_modules/tar/dist/commonjs/create.js +150 -64
- package/node_modules/tar/dist/commonjs/dealias.d.ts +79 -0
- package/node_modules/tar/dist/commonjs/dealias.js +50 -0
- package/node_modules/tar/dist/commonjs/delete.d.ts +19 -0
- package/node_modules/tar/dist/commonjs/delete.js +121 -0
- package/node_modules/tar/dist/commonjs/entries.d.ts +82 -0
- package/node_modules/tar/dist/commonjs/entries.js +398 -0
- package/node_modules/tar/dist/commonjs/extract.d.ts +14 -2
- package/node_modules/tar/dist/commonjs/extract.js +40 -81
- package/node_modules/tar/dist/commonjs/fs.d.ts +201 -0
- package/node_modules/tar/dist/commonjs/fs.js +5 -0
- package/node_modules/tar/dist/commonjs/header.d.ts +4 -4
- package/node_modules/tar/dist/commonjs/header.js +71 -53
- package/node_modules/tar/dist/commonjs/index.d.ts +25 -18
- package/node_modules/tar/dist/commonjs/index.js +46 -18
- package/node_modules/tar/dist/commonjs/index.min.js +2 -3
- package/node_modules/tar/dist/commonjs/large-numbers.d.ts +2 -2
- package/node_modules/tar/dist/commonjs/large-numbers.js +4 -4
- package/node_modules/tar/dist/commonjs/list.d.ts +23 -6
- package/node_modules/tar/dist/commonjs/list.js +99 -138
- package/node_modules/tar/dist/commonjs/mkdir.d.ts +16 -11
- package/node_modules/tar/dist/commonjs/mkdir.js +121 -159
- package/node_modules/tar/dist/commonjs/normalize-unicode.js +9 -0
- package/node_modules/tar/dist/commonjs/options.d.ts +284 -513
- package/node_modules/tar/dist/commonjs/options.js +20 -61
- package/node_modules/tar/dist/commonjs/pack.d.ts +150 -96
- package/node_modules/tar/dist/commonjs/pack.js +752 -445
- package/node_modules/tar/dist/commonjs/parser.d.ts +98 -0
- package/node_modules/tar/dist/commonjs/parser.js +452 -0
- package/node_modules/tar/dist/commonjs/path-reservations.d.ts +17 -7
- package/node_modules/tar/dist/commonjs/path-reservations.js +110 -140
- package/node_modules/tar/dist/commonjs/path.d.ts +19 -0
- package/node_modules/tar/dist/commonjs/path.js +90 -0
- package/node_modules/tar/dist/commonjs/pax.d.ts +3 -1
- package/node_modules/tar/dist/commonjs/pax.js +67 -36
- package/node_modules/tar/dist/commonjs/read-entry.d.ts +97 -11
- package/node_modules/tar/dist/commonjs/read-entry.js +251 -97
- package/node_modules/tar/dist/commonjs/read-file.d.ts +22 -0
- package/node_modules/tar/dist/commonjs/read-file.js +104 -0
- package/node_modules/tar/dist/commonjs/replace.d.ts +45 -1
- package/node_modules/tar/dist/commonjs/replace.js +164 -211
- package/node_modules/tar/dist/commonjs/server/codecs.d.ts +38 -0
- package/node_modules/tar/dist/commonjs/server/codecs.js +252 -0
- package/node_modules/tar/dist/commonjs/server/index.d.ts +115 -0
- package/node_modules/tar/dist/commonjs/server/index.js +166 -0
- package/node_modules/tar/dist/commonjs/server/index.min.js +3 -0
- package/node_modules/tar/dist/commonjs/strip-absolute-path.d.ts +8 -0
- package/node_modules/tar/dist/commonjs/strip-absolute-path.js +17 -20
- package/node_modules/tar/dist/commonjs/to-stream.d.ts +7 -0
- package/node_modules/tar/dist/commonjs/to-stream.js +22 -0
- package/node_modules/tar/dist/commonjs/types.d.ts +4 -3
- package/node_modules/tar/dist/commonjs/types.js +4 -3
- package/node_modules/tar/dist/commonjs/unpack.d.ts +143 -89
- package/node_modules/tar/dist/commonjs/unpack.js +780 -725
- package/node_modules/tar/dist/commonjs/update.d.ts +11 -1
- package/node_modules/tar/dist/commonjs/update.js +37 -28
- package/node_modules/tar/dist/commonjs/warn.d.ts +27 -0
- package/node_modules/tar/dist/commonjs/warn.js +36 -0
- package/node_modules/tar/dist/commonjs/win32-path.d.ts +16 -0
- package/node_modules/tar/dist/commonjs/win32-path.js +67 -0
- package/node_modules/tar/dist/commonjs/write-entry.d.ts +64 -111
- package/node_modules/tar/dist/commonjs/write-entry.js +108 -672
- package/node_modules/tar/dist/commonjs/write-flag.d.ts +18 -0
- package/node_modules/tar/dist/commonjs/write-flag.js +29 -0
- package/node_modules/tar/dist/esm/bytes.d.ts +21 -0
- package/node_modules/tar/dist/esm/bytes.js +72 -0
- package/node_modules/tar/dist/esm/codec.d.ts +53 -0
- package/node_modules/tar/dist/esm/codec.js +32 -0
- package/node_modules/tar/dist/esm/concat.d.ts +3 -0
- package/node_modules/tar/dist/esm/concat.js +16 -0
- package/node_modules/tar/dist/esm/create.d.ts +39 -2
- package/node_modules/tar/dist/esm/create.js +144 -61
- package/node_modules/tar/dist/esm/dealias.d.ts +79 -0
- package/node_modules/tar/dist/esm/dealias.js +46 -0
- package/node_modules/tar/dist/esm/delete.d.ts +19 -0
- package/node_modules/tar/dist/esm/delete.js +117 -0
- package/node_modules/tar/dist/esm/entries.d.ts +82 -0
- package/node_modules/tar/dist/esm/entries.js +388 -0
- package/node_modules/tar/dist/esm/extract.d.ts +14 -2
- package/node_modules/tar/dist/esm/extract.js +37 -44
- package/node_modules/tar/dist/esm/fs.d.ts +201 -0
- package/node_modules/tar/dist/esm/fs.js +4 -0
- package/node_modules/tar/dist/esm/header.d.ts +4 -4
- package/node_modules/tar/dist/esm/header.js +71 -53
- package/node_modules/tar/dist/esm/index.d.ts +25 -18
- package/node_modules/tar/dist/esm/index.js +23 -18
- package/node_modules/tar/dist/esm/index.min.js +2 -3
- package/node_modules/tar/dist/esm/large-numbers.d.ts +2 -2
- package/node_modules/tar/dist/esm/large-numbers.js +4 -4
- package/node_modules/tar/dist/esm/list.d.ts +23 -6
- package/node_modules/tar/dist/esm/list.js +96 -101
- package/node_modules/tar/dist/esm/mkdir.d.ts +16 -11
- package/node_modules/tar/dist/esm/mkdir.js +119 -154
- package/node_modules/tar/dist/esm/normalize-unicode.js +9 -0
- package/node_modules/tar/dist/esm/options.d.ts +284 -513
- package/node_modules/tar/dist/esm/options.js +17 -51
- package/node_modules/tar/dist/esm/pack.d.ts +150 -96
- package/node_modules/tar/dist/esm/pack.js +750 -441
- package/node_modules/tar/dist/esm/parser.d.ts +98 -0
- package/node_modules/tar/dist/esm/parser.js +448 -0
- package/node_modules/tar/dist/esm/path-reservations.d.ts +17 -7
- package/node_modules/tar/dist/esm/path-reservations.js +110 -140
- package/node_modules/tar/dist/esm/path.d.ts +19 -0
- package/node_modules/tar/dist/esm/path.js +80 -0
- package/node_modules/tar/dist/esm/pax.d.ts +3 -1
- package/node_modules/tar/dist/esm/pax.js +66 -35
- package/node_modules/tar/dist/esm/read-entry.d.ts +97 -11
- package/node_modules/tar/dist/esm/read-entry.js +248 -96
- package/node_modules/tar/dist/esm/read-file.d.ts +22 -0
- package/node_modules/tar/dist/esm/read-file.js +99 -0
- package/node_modules/tar/dist/esm/replace.d.ts +45 -1
- package/node_modules/tar/dist/esm/replace.js +160 -207
- package/node_modules/tar/dist/esm/server/codecs.d.ts +38 -0
- package/node_modules/tar/dist/esm/server/codecs.js +214 -0
- package/node_modules/tar/dist/esm/server/index.d.ts +115 -0
- package/node_modules/tar/dist/esm/server/index.js +102 -0
- package/node_modules/tar/dist/esm/server/index.min.js +3 -0
- package/node_modules/tar/dist/esm/strip-absolute-path.d.ts +8 -0
- package/node_modules/tar/dist/esm/strip-absolute-path.js +17 -20
- package/node_modules/tar/dist/esm/to-stream.d.ts +7 -0
- package/node_modules/tar/dist/esm/to-stream.js +18 -0
- package/node_modules/tar/dist/esm/types.d.ts +4 -3
- package/node_modules/tar/dist/esm/types.js +4 -3
- package/node_modules/tar/dist/esm/unpack.d.ts +143 -89
- package/node_modules/tar/dist/esm/unpack.js +776 -719
- package/node_modules/tar/dist/esm/update.d.ts +11 -1
- package/node_modules/tar/dist/esm/update.js +35 -28
- package/node_modules/tar/dist/esm/warn.d.ts +27 -0
- package/node_modules/tar/dist/esm/warn.js +31 -0
- package/node_modules/tar/dist/esm/win32-path.d.ts +16 -0
- package/node_modules/tar/dist/esm/win32-path.js +60 -0
- package/node_modules/tar/dist/esm/write-entry.d.ts +64 -111
- package/node_modules/tar/dist/esm/write-entry.js +107 -633
- package/node_modules/tar/dist/esm/write-flag.d.ts +18 -0
- package/node_modules/tar/dist/esm/write-flag.js +25 -0
- package/node_modules/tar/package.json +68 -224
- package/package.json +2 -2
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-AJLU6KLW.js +0 -2
- package/node_modules/@isaacs/fs-minipass/LICENSE +0 -15
- package/node_modules/@isaacs/fs-minipass/README.md +0 -71
- package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.d.ts +0 -118
- package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js +0 -430
- package/node_modules/@isaacs/fs-minipass/dist/commonjs/package.json +0 -3
- package/node_modules/@isaacs/fs-minipass/dist/esm/index.d.ts +0 -118
- package/node_modules/@isaacs/fs-minipass/dist/esm/index.js +0 -420
- package/node_modules/@isaacs/fs-minipass/dist/esm/package.json +0 -3
- package/node_modules/@isaacs/fs-minipass/package.json +0 -72
- package/node_modules/chownr/LICENSE.md +0 -63
- package/node_modules/chownr/README.md +0 -3
- package/node_modules/chownr/dist/commonjs/index.d.ts +0 -3
- package/node_modules/chownr/dist/commonjs/index.js +0 -93
- package/node_modules/chownr/dist/commonjs/package.json +0 -3
- package/node_modules/chownr/dist/esm/index.d.ts +0 -3
- package/node_modules/chownr/dist/esm/index.js +0 -85
- package/node_modules/chownr/dist/esm/package.json +0 -3
- package/node_modules/chownr/package.json +0 -69
- package/node_modules/minipass/LICENSE.md +0 -55
- package/node_modules/minipass/README.md +0 -825
- package/node_modules/minipass/dist/commonjs/index.d.ts +0 -545
- package/node_modules/minipass/dist/commonjs/index.js +0 -1038
- package/node_modules/minipass/dist/commonjs/package.json +0 -3
- package/node_modules/minipass/dist/esm/index.d.ts +0 -545
- package/node_modules/minipass/dist/esm/index.js +0 -1020
- package/node_modules/minipass/dist/esm/package.json +0 -3
- package/node_modules/minipass/package.json +0 -77
- package/node_modules/minizlib/LICENSE +0 -26
- package/node_modules/minizlib/README.md +0 -64
- package/node_modules/minizlib/dist/commonjs/constants.d.ts +0 -2
- package/node_modules/minizlib/dist/commonjs/constants.js +0 -123
- package/node_modules/minizlib/dist/commonjs/index.d.ts +0 -99
- package/node_modules/minizlib/dist/commonjs/index.js +0 -416
- package/node_modules/minizlib/dist/commonjs/package.json +0 -3
- package/node_modules/minizlib/dist/esm/constants.d.ts +0 -2
- package/node_modules/minizlib/dist/esm/constants.js +0 -117
- package/node_modules/minizlib/dist/esm/index.d.ts +0 -99
- package/node_modules/minizlib/dist/esm/index.js +0 -363
- package/node_modules/minizlib/dist/esm/package.json +0 -3
- package/node_modules/minizlib/package.json +0 -80
- package/node_modules/tar/dist/commonjs/get-write-flag.d.ts +0 -2
- package/node_modules/tar/dist/commonjs/get-write-flag.js +0 -32
- package/node_modules/tar/dist/commonjs/make-command.d.ts +0 -49
- package/node_modules/tar/dist/commonjs/make-command.js +0 -52
- package/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts +0 -2
- package/node_modules/tar/dist/commonjs/normalize-windows-path.js +0 -12
- package/node_modules/tar/dist/commonjs/parse.d.ts +0 -92
- package/node_modules/tar/dist/commonjs/parse.js +0 -655
- package/node_modules/tar/dist/commonjs/process-umask.d.ts +0 -2
- package/node_modules/tar/dist/commonjs/process-umask.js +0 -7
- package/node_modules/tar/dist/commonjs/warn-method.d.ts +0 -24
- package/node_modules/tar/dist/commonjs/warn-method.js +0 -31
- package/node_modules/tar/dist/esm/get-write-flag.d.ts +0 -2
- package/node_modules/tar/dist/esm/get-write-flag.js +0 -26
- package/node_modules/tar/dist/esm/make-command.d.ts +0 -49
- package/node_modules/tar/dist/esm/make-command.js +0 -48
- package/node_modules/tar/dist/esm/normalize-windows-path.d.ts +0 -2
- package/node_modules/tar/dist/esm/normalize-windows-path.js +0 -9
- package/node_modules/tar/dist/esm/parse.d.ts +0 -92
- package/node_modules/tar/dist/esm/parse.js +0 -651
- package/node_modules/tar/dist/esm/process-umask.d.ts +0 -2
- package/node_modules/tar/dist/esm/process-umask.js +0 -3
- package/node_modules/tar/dist/esm/warn-method.d.ts +0 -24
- package/node_modules/tar/dist/esm/warn-method.js +0 -27
- package/node_modules/yallist/LICENSE.md +0 -63
- package/node_modules/yallist/README.md +0 -205
- package/node_modules/yallist/dist/commonjs/index.d.ts +0 -39
- package/node_modules/yallist/dist/commonjs/index.js +0 -384
- package/node_modules/yallist/dist/commonjs/package.json +0 -3
- package/node_modules/yallist/dist/esm/index.d.ts +0 -39
- package/node_modules/yallist/dist/esm/index.js +0 -379
- package/node_modules/yallist/dist/esm/package.json +0 -3
- package/node_modules/yallist/package.json +0 -68
|
@@ -1,373 +1,331 @@
|
|
|
1
|
-
|
|
2
|
-
// but the path reservations are required to avoid race conditions where
|
|
3
|
-
// parallelized unpack ops may mess with one another, due to dependencies
|
|
4
|
-
// (like a Link depending on its target) or destructive operations (like
|
|
5
|
-
// clobbering an fs object to create one of a different type.)
|
|
6
|
-
import * as fsm from '@isaacs/fs-minipass';
|
|
7
|
-
import assert from 'node:assert';
|
|
8
|
-
import { randomBytes } from 'node:crypto';
|
|
9
|
-
import fs from 'node:fs';
|
|
10
|
-
import path from 'node:path';
|
|
11
|
-
import { getWriteFlag } from './get-write-flag.js';
|
|
12
|
-
import { mkdir, mkdirSync } from './mkdir.js';
|
|
13
|
-
import { normalizeWindowsPath } from './normalize-windows-path.js';
|
|
14
|
-
import { Parser } from './parse.js';
|
|
15
|
-
import { stripAbsolutePath } from './strip-absolute-path.js';
|
|
1
|
+
import { SymlinkError } from './symlink-error.js';
|
|
16
2
|
import * as wc from './winchars.js';
|
|
3
|
+
import { TarReader, TarReaderSync } from './entries.js';
|
|
4
|
+
import { mkdir, mkdirSync } from './mkdir.js';
|
|
5
|
+
import { countOption, ownOptions, } from './options.js';
|
|
17
6
|
import { PathReservations } from './path-reservations.js';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const ISREUSABLE = Symbol('isReusable');
|
|
24
|
-
const MAKEFS = Symbol('makeFs');
|
|
25
|
-
const FILE = Symbol('file');
|
|
26
|
-
const DIRECTORY = Symbol('directory');
|
|
27
|
-
const LINK = Symbol('link');
|
|
28
|
-
const SYMLINK = Symbol('symlink');
|
|
29
|
-
const HARDLINK = Symbol('hardlink');
|
|
30
|
-
const ENSURE_NO_SYMLINK = Symbol('ensureNoSymlink');
|
|
31
|
-
const UNSUPPORTED = Symbol('unsupported');
|
|
32
|
-
const CHECKPATH = Symbol('checkPath');
|
|
33
|
-
const STRIPABSOLUTEPATH = Symbol('stripAbsolutePath');
|
|
34
|
-
const MKDIR = Symbol('mkdir');
|
|
35
|
-
const ONERROR = Symbol('onError');
|
|
36
|
-
const PENDING = Symbol('pending');
|
|
37
|
-
const PEND = Symbol('pend');
|
|
38
|
-
const UNPEND = Symbol('unpend');
|
|
39
|
-
const ENDED = Symbol('ended');
|
|
40
|
-
const MAYBECLOSE = Symbol('maybeClose');
|
|
41
|
-
const SKIP = Symbol('skip');
|
|
42
|
-
const DOCHOWN = Symbol('doChown');
|
|
43
|
-
const UID = Symbol('uid');
|
|
44
|
-
const GID = Symbol('gid');
|
|
45
|
-
const CHECKED_CWD = Symbol('checkedCwd');
|
|
46
|
-
const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
47
|
-
const isWindows = platform === 'win32';
|
|
7
|
+
import { dirname, isAbsolute, join, normalize, relative, resolve, } from './path.js';
|
|
8
|
+
import { stripAbsolutePath } from './strip-absolute-path.js';
|
|
9
|
+
import { warn } from './warn.js';
|
|
10
|
+
import { win32Dirname, win32IsAbsolute, win32Resolve, win32Root, } from './win32-path.js';
|
|
11
|
+
import { writeFlags } from './write-flag.js';
|
|
48
12
|
const DEFAULT_MAX_DEPTH = 1024;
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
//
|
|
63
|
-
// See: https://github.com/npm/node-tar/issues/183
|
|
64
|
-
/* c8 ignore start */
|
|
65
|
-
const unlinkFile = (path, cb) => {
|
|
66
|
-
if (!isWindows) {
|
|
67
|
-
return fs.unlink(path, cb);
|
|
68
|
-
}
|
|
69
|
-
const name = path + '.DELETE.' + randomBytes(16).toString('hex');
|
|
70
|
-
fs.rename(path, name, er => {
|
|
71
|
-
if (er) {
|
|
72
|
-
return cb(er);
|
|
73
|
-
}
|
|
74
|
-
fs.unlink(name, cb);
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
/* c8 ignore stop */
|
|
78
|
-
/* c8 ignore start */
|
|
79
|
-
const unlinkFileSync = (path) => {
|
|
80
|
-
if (!isWindows) {
|
|
81
|
-
return fs.unlinkSync(path);
|
|
82
|
-
}
|
|
83
|
-
const name = path + '.DELETE.' + randomBytes(16).toString('hex');
|
|
84
|
-
fs.renameSync(path, name);
|
|
85
|
-
fs.unlinkSync(name);
|
|
86
|
-
};
|
|
87
|
-
/* c8 ignore stop */
|
|
88
|
-
// this.gid, entry.gid, this.processUid
|
|
89
|
-
const uint32 = (a, b, c) => a !== undefined && a === a >>> 0 ? a
|
|
13
|
+
// Longer than any path that a supported platform can create.
|
|
14
|
+
const MAX_PATH_LENGTH = 32768;
|
|
15
|
+
const DEFAULT_JOBS = 16;
|
|
16
|
+
const fileTypes = new Set([
|
|
17
|
+
'File',
|
|
18
|
+
'OldFile',
|
|
19
|
+
'ContiguousFile',
|
|
20
|
+
]);
|
|
21
|
+
const dirTypes = new Set(['Directory', 'GNUDumpDir']);
|
|
22
|
+
const linkTypes = new Set(['Link', 'SymbolicLink']);
|
|
23
|
+
// The first of the values that is an unsigned 32-bit integer, or the
|
|
24
|
+
// last value.
|
|
25
|
+
const uint32 = (a, b, c) => a !== undefined ? a
|
|
90
26
|
: b !== undefined && b === b >>> 0 ? b
|
|
91
27
|
: c;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
28
|
+
/**
|
|
29
|
+
* The parts of the extraction that do not use the file system: the
|
|
30
|
+
* options, the checks of each entry, and the warnings. `Unpack` and
|
|
31
|
+
* `UnpackSync` add the file system work.
|
|
32
|
+
*/
|
|
33
|
+
export class UnpackBase {
|
|
34
|
+
/** The options, with no prototype. */
|
|
35
|
+
opt;
|
|
36
|
+
/** The absolute path of the extraction directory. */
|
|
37
|
+
cwd;
|
|
38
|
+
win32;
|
|
39
|
+
strip;
|
|
40
|
+
maxDepth;
|
|
41
|
+
preservePaths;
|
|
42
|
+
unlink;
|
|
43
|
+
keep;
|
|
44
|
+
newer;
|
|
45
|
+
noMtime;
|
|
46
|
+
chmod;
|
|
100
47
|
uid;
|
|
101
48
|
gid;
|
|
102
|
-
setOwner;
|
|
103
49
|
preserveOwner;
|
|
104
|
-
processGid;
|
|
105
|
-
processUid;
|
|
106
|
-
maxDepth;
|
|
107
50
|
forceChown;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
keep;
|
|
111
|
-
noMtime;
|
|
112
|
-
preservePaths;
|
|
113
|
-
unlink;
|
|
114
|
-
cwd;
|
|
115
|
-
strip;
|
|
51
|
+
processUid;
|
|
52
|
+
processGid;
|
|
116
53
|
processUmask;
|
|
117
54
|
umask;
|
|
118
55
|
dmode;
|
|
119
56
|
fmode;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
57
|
+
/** Gives the `open` flag for a new file of a given size. */
|
|
58
|
+
writeFlag;
|
|
59
|
+
/** Resolve a path from an absolute path. */
|
|
60
|
+
resolve;
|
|
61
|
+
/** The parent directory of an absolute path. */
|
|
62
|
+
dirname;
|
|
63
|
+
/** Set when an error stops the extraction. */
|
|
64
|
+
fatal;
|
|
65
|
+
constructor(options) {
|
|
66
|
+
const opt = (this.opt = ownOptions(options));
|
|
67
|
+
const win32 = (this.win32 = opt.platform === 'win32');
|
|
68
|
+
this.resolve = win32 ? win32Resolve : resolve;
|
|
69
|
+
this.dirname = win32 ? win32Dirname : dirname;
|
|
70
|
+
if (typeof opt.cwd !== 'string') {
|
|
71
|
+
throw new TypeError('cwd is required');
|
|
72
|
+
}
|
|
73
|
+
const cwd = win32 ? opt.cwd.replaceAll('\\', '/') : opt.cwd;
|
|
74
|
+
if (!(win32 ? win32IsAbsolute : isAbsolute)(cwd)) {
|
|
75
|
+
throw new TypeError('cwd must be an absolute path');
|
|
76
|
+
}
|
|
77
|
+
this.cwd = this.resolve(cwd, '');
|
|
129
78
|
if (typeof opt.uid === 'number' || typeof opt.gid === 'number') {
|
|
130
79
|
// need both or neither
|
|
131
80
|
if (typeof opt.uid !== 'number' || typeof opt.gid !== 'number') {
|
|
132
81
|
throw new TypeError('cannot set owner without number uid and gid');
|
|
133
82
|
}
|
|
83
|
+
// A value that is not valid must not fall back to the owner
|
|
84
|
+
// in the archive.
|
|
85
|
+
if (opt.uid !== opt.uid >>> 0 || opt.gid !== opt.gid >>> 0) {
|
|
86
|
+
throw new TypeError('uid and gid must be unsigned 32-bit integers');
|
|
87
|
+
}
|
|
134
88
|
if (opt.preserveOwner) {
|
|
135
89
|
throw new TypeError('cannot preserve owner in archive and also set owner explicitly');
|
|
136
90
|
}
|
|
137
91
|
this.uid = opt.uid;
|
|
138
92
|
this.gid = opt.gid;
|
|
139
|
-
this.setOwner = true;
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
this.uid = undefined;
|
|
143
|
-
this.gid = undefined;
|
|
144
|
-
this.setOwner = false;
|
|
145
93
|
}
|
|
146
|
-
|
|
94
|
+
this.processUid = opt.processUid;
|
|
95
|
+
this.processGid = opt.processGid;
|
|
147
96
|
this.preserveOwner =
|
|
148
97
|
opt.preserveOwner === undefined && typeof opt.uid !== 'number' ?
|
|
149
|
-
|
|
98
|
+
opt.processUid === 0
|
|
150
99
|
: !!opt.preserveOwner;
|
|
151
|
-
this.
|
|
152
|
-
(this.preserveOwner || this.setOwner) && process.getuid ?
|
|
153
|
-
process.getuid()
|
|
154
|
-
: undefined;
|
|
155
|
-
this.processGid =
|
|
156
|
-
(this.preserveOwner || this.setOwner) && process.getgid ?
|
|
157
|
-
process.getgid()
|
|
158
|
-
: undefined;
|
|
159
|
-
// prevent excessively deep nesting of subfolders
|
|
160
|
-
// set to `Infinity` to remove this restriction
|
|
100
|
+
this.forceChown = opt.forceChown === true;
|
|
161
101
|
this.maxDepth =
|
|
162
102
|
typeof opt.maxDepth === 'number' ? opt.maxDepth : DEFAULT_MAX_DEPTH;
|
|
163
|
-
|
|
164
|
-
// Forcibly trigger a chown on every entry, no matter what
|
|
165
|
-
this.forceChown = opt.forceChown === true;
|
|
166
|
-
// turn ><?| in filenames into 0xf000-higher encoded forms
|
|
167
|
-
this.win32 = !!opt.win32 || isWindows;
|
|
168
|
-
// do not unpack over files that are newer than what's in the archive
|
|
169
|
-
this.newer = !!opt.newer;
|
|
170
|
-
// do not unpack over ANY files
|
|
171
|
-
this.keep = !!opt.keep;
|
|
172
|
-
// do not set mtime/atime of extracted entries
|
|
173
|
-
this.noMtime = !!opt.noMtime;
|
|
174
|
-
// allow .., absolute path entries, and unpacking through symlinks
|
|
175
|
-
// without this, warn and skip .., relativize absolutes, and error
|
|
176
|
-
// on symlinks in extraction path
|
|
103
|
+
this.strip = Number(opt.strip) || 0;
|
|
177
104
|
this.preservePaths = !!opt.preservePaths;
|
|
178
|
-
// unlink files and links before writing. This breaks existing hard
|
|
179
|
-
// links, and removes symlink directories rather than erroring
|
|
180
105
|
this.unlink = !!opt.unlink;
|
|
181
|
-
this.
|
|
182
|
-
this.
|
|
183
|
-
|
|
106
|
+
this.keep = !!opt.keep;
|
|
107
|
+
this.newer = !!opt.newer;
|
|
108
|
+
this.noMtime = !!opt.noMtime;
|
|
109
|
+
this.chmod = !!opt.chmod;
|
|
110
|
+
// Without chmod, the umask of the process is not needed.
|
|
184
111
|
this.processUmask =
|
|
185
112
|
!this.chmod ? 0
|
|
186
113
|
: typeof opt.processUmask === 'number' ? opt.processUmask
|
|
187
|
-
:
|
|
114
|
+
: 0o22;
|
|
188
115
|
this.umask =
|
|
189
116
|
typeof opt.umask === 'number' ? opt.umask : this.processUmask;
|
|
190
|
-
|
|
191
|
-
this.
|
|
192
|
-
this.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
117
|
+
this.dmode = opt.dmode || 0o777 & ~this.umask;
|
|
118
|
+
this.fmode = opt.fmode || 0o666 & ~this.umask;
|
|
119
|
+
this.writeFlag = writeFlags(opt.fs.constants, win32);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Report a problem to `onwarn`, or throw it if `strict` is set. A
|
|
123
|
+
* damaged archive is always an error here, because the extraction
|
|
124
|
+
* cannot be complete.
|
|
125
|
+
*/
|
|
126
|
+
warn(code, message, data = {}) {
|
|
199
127
|
if (code === 'TAR_BAD_ARCHIVE' || code === 'TAR_ABORT') {
|
|
200
128
|
data.recoverable = false;
|
|
201
129
|
}
|
|
202
|
-
|
|
130
|
+
data.cwd = this.cwd;
|
|
131
|
+
warn(this.opt, code, message, data);
|
|
203
132
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
this.
|
|
209
|
-
}
|
|
133
|
+
/** The options for the reader. Its warnings go to `warn()`. */
|
|
134
|
+
readerOptions() {
|
|
135
|
+
return ownOptions(this.opt, {
|
|
136
|
+
strict: false,
|
|
137
|
+
onwarn: (code, message, data) => this.warn(code, message, data),
|
|
138
|
+
});
|
|
210
139
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Report the failure of one entry as a `TAR_ENTRY_ERROR` warning.
|
|
142
|
+
* Throws the error if it stops the extraction: the extraction
|
|
143
|
+
* directory is not usable, the archive cannot be read, or `strict`
|
|
144
|
+
* is set.
|
|
145
|
+
*/
|
|
146
|
+
entryError(er, entry) {
|
|
147
|
+
if (this.fatal?.error === er || er?.name === 'CwdError') {
|
|
148
|
+
throw er;
|
|
149
|
+
}
|
|
150
|
+
this.warn('TAR_ENTRY_ERROR', er, { entry });
|
|
151
|
+
}
|
|
152
|
+
/** Record the error that stops the extraction. Returns it. */
|
|
153
|
+
fail(error) {
|
|
154
|
+
this.fatal ??= { error };
|
|
155
|
+
return error;
|
|
156
|
+
}
|
|
157
|
+
// Remove the root of an absolute path, and refuse a path that can
|
|
158
|
+
// leave the extraction directory. False if the entry is refused.
|
|
159
|
+
#stripAbsolutePath(entry, field) {
|
|
214
160
|
const p = entry[field];
|
|
215
|
-
const { type } = entry;
|
|
216
161
|
if (!p || this.preservePaths)
|
|
217
162
|
return true;
|
|
218
|
-
// strip off the root
|
|
219
163
|
const [root, stripped] = stripAbsolutePath(p);
|
|
220
|
-
const parts = stripped.replaceAll(
|
|
221
|
-
if (parts.includes('..')
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
//
|
|
225
|
-
|
|
226
|
-
// '../sibling/file' are valid if they resolve within the cwd.
|
|
227
|
-
// For paths, they just simply may not ever use .. at all.
|
|
228
|
-
if (field === 'path' || type === 'Link') {
|
|
164
|
+
const parts = stripped.replaceAll('\\', '/').split('/');
|
|
165
|
+
if (parts.includes('..')) {
|
|
166
|
+
// A path, and the target of a hard link, cannot have '..' at
|
|
167
|
+
// all. The target of a symbolic link is relative to the
|
|
168
|
+
// directory of the link, so '../sibling/file' can be valid.
|
|
169
|
+
if (field === 'path' || entry.type === 'Link') {
|
|
229
170
|
this.warn('TAR_ENTRY_ERROR', `${field} contains '..'`, {
|
|
230
171
|
entry,
|
|
231
172
|
[field]: p,
|
|
232
173
|
});
|
|
233
|
-
// not ok!
|
|
234
174
|
return false;
|
|
235
175
|
}
|
|
236
|
-
//
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
176
|
+
// A '..' is only safe at the start of the target. Any named
|
|
177
|
+
// part before it can be a symlink, and then the '..' goes to
|
|
178
|
+
// the parent of the target of that symlink.
|
|
179
|
+
const firstName = parts.findIndex(part => part !== '..' && part !== '.' && part !== '');
|
|
180
|
+
if (firstName !== -1 && parts.includes('..', firstName)) {
|
|
181
|
+
this.warn('TAR_ENTRY_ERROR', `${field} contains '..' after a path portion`, { entry, [field]: p });
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
// Normalize the path, so that the directory is the one where
|
|
185
|
+
// the link is created. The path 'x/.' creates the link 'x'.
|
|
186
|
+
const entryDir = dirname(normalize(entry.path));
|
|
187
|
+
const resolved = normalize(join(entryDir, parts.join('/')));
|
|
242
188
|
if (resolved.startsWith('../') || resolved === '..') {
|
|
243
|
-
this.warn('TAR_ENTRY_ERROR', `${field} escapes extraction directory`, {
|
|
244
|
-
entry,
|
|
245
|
-
[field]: p,
|
|
246
|
-
});
|
|
189
|
+
this.warn('TAR_ENTRY_ERROR', `${field} escapes extraction directory`, { entry, [field]: p });
|
|
247
190
|
return false;
|
|
248
191
|
}
|
|
249
192
|
}
|
|
250
193
|
if (root) {
|
|
251
|
-
|
|
252
|
-
entry[field] =
|
|
253
|
-
this.warn('TAR_ENTRY_INFO', `stripping ${root} from absolute ${field}`, {
|
|
254
|
-
entry,
|
|
255
|
-
[field]: p,
|
|
256
|
-
});
|
|
194
|
+
;
|
|
195
|
+
entry[field] = stripped;
|
|
196
|
+
this.warn('TAR_ENTRY_INFO', `stripping ${root} from absolute ${field}`, { entry, [field]: p });
|
|
257
197
|
}
|
|
258
198
|
return true;
|
|
259
199
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Check the entry, with no use of the file system. Set its
|
|
202
|
+
* `absolute` path, and change its `path`, `linkpath`, and `mode` to
|
|
203
|
+
* the values to extract. False if the entry must not be extracted.
|
|
204
|
+
*/
|
|
205
|
+
check(entry) {
|
|
206
|
+
const p = entry.path;
|
|
263
207
|
const parts = p.split('/');
|
|
264
208
|
if (this.strip) {
|
|
265
|
-
if (parts.length < this.strip)
|
|
209
|
+
if (parts.length < this.strip)
|
|
266
210
|
return false;
|
|
267
|
-
}
|
|
268
211
|
if (entry.type === 'Link') {
|
|
269
|
-
const linkparts =
|
|
270
|
-
if (linkparts.length
|
|
271
|
-
entry.linkpath = linkparts.slice(this.strip).join('/');
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
212
|
+
const linkparts = String(entry.linkpath).split('/');
|
|
213
|
+
if (linkparts.length < this.strip)
|
|
274
214
|
return false;
|
|
275
|
-
|
|
215
|
+
entry.linkpath = linkparts.slice(this.strip).join('/');
|
|
276
216
|
}
|
|
277
217
|
parts.splice(0, this.strip);
|
|
218
|
+
// No part of the path is left, as for the top directory of a
|
|
219
|
+
// package. The entry must not change the extraction directory.
|
|
220
|
+
if (parts.every(part => part === ''))
|
|
221
|
+
return false;
|
|
278
222
|
entry.path = parts.join('/');
|
|
279
223
|
}
|
|
280
|
-
|
|
224
|
+
const { maxDepth } = this;
|
|
225
|
+
if (isFinite(maxDepth) && parts.length > maxDepth) {
|
|
281
226
|
this.warn('TAR_ENTRY_ERROR', 'path excessively deep', {
|
|
282
227
|
entry,
|
|
283
228
|
path: p,
|
|
284
229
|
depth: parts.length,
|
|
285
|
-
maxDepth
|
|
230
|
+
maxDepth,
|
|
231
|
+
});
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
// The path reservations do work for each parent directory of the
|
|
235
|
+
// path and of the linkpath.
|
|
236
|
+
const { linkpath } = entry;
|
|
237
|
+
if (linkpath &&
|
|
238
|
+
isFinite(maxDepth) &&
|
|
239
|
+
linkpath.split('/').length > maxDepth) {
|
|
240
|
+
this.warn('TAR_ENTRY_ERROR', 'linkpath excessively deep', {
|
|
241
|
+
entry,
|
|
242
|
+
path: p,
|
|
243
|
+
linkpath,
|
|
244
|
+
maxDepth,
|
|
286
245
|
});
|
|
287
246
|
return false;
|
|
288
247
|
}
|
|
289
|
-
|
|
290
|
-
|
|
248
|
+
for (const field of ['path', 'linkpath']) {
|
|
249
|
+
const { length } = entry[field] ?? '';
|
|
250
|
+
if (length > MAX_PATH_LENGTH) {
|
|
251
|
+
this.warn('TAR_ENTRY_ERROR', `${field} excessively long`, {
|
|
252
|
+
entry,
|
|
253
|
+
path: p,
|
|
254
|
+
length,
|
|
255
|
+
maxLength: MAX_PATH_LENGTH,
|
|
256
|
+
});
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (!this.#stripAbsolutePath(entry, 'path') ||
|
|
261
|
+
!this.#stripAbsolutePath(entry, 'linkpath')) {
|
|
291
262
|
return false;
|
|
292
263
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
// if we somehow ended up with a path that escapes the cwd, and we are
|
|
298
|
-
// not in preservePaths mode, then something is fishy! This should have
|
|
299
|
-
// been prevented above, so ignore this for coverage.
|
|
300
|
-
/* c8 ignore start - defense in depth */
|
|
264
|
+
const { cwd } = this;
|
|
265
|
+
let absolute = this.resolve(cwd, entry.path);
|
|
266
|
+
// The checks above refuse a path that leaves the extraction
|
|
267
|
+
// directory. This check is defense in depth.
|
|
301
268
|
if (!this.preservePaths &&
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
269
|
+
absolute !== cwd &&
|
|
270
|
+
// A root, such as `/` or `c:/`, ends with a slash.
|
|
271
|
+
!absolute.startsWith(cwd.endsWith('/') ? cwd : cwd + '/')) {
|
|
305
272
|
this.warn('TAR_ENTRY_ERROR', 'path escaped extraction target', {
|
|
306
273
|
entry,
|
|
307
|
-
path:
|
|
308
|
-
resolvedPath:
|
|
309
|
-
cwd
|
|
274
|
+
path: entry.path,
|
|
275
|
+
resolvedPath: absolute,
|
|
276
|
+
cwd,
|
|
310
277
|
});
|
|
311
278
|
return false;
|
|
312
279
|
}
|
|
313
|
-
|
|
314
|
-
//
|
|
315
|
-
|
|
316
|
-
if (entry.absolute === this.cwd &&
|
|
317
|
-
entry.type !== 'Directory' &&
|
|
318
|
-
entry.type !== 'GNUDumpDir') {
|
|
280
|
+
// An archive can set properties of the extraction directory, but
|
|
281
|
+
// it cannot replace it with a different kind of thing.
|
|
282
|
+
if (absolute === cwd && !dirTypes.has(entry.type))
|
|
319
283
|
return false;
|
|
320
|
-
|
|
321
|
-
// only encode : chars that aren't drive letter indicators
|
|
284
|
+
// Do not change the ':' of a drive letter.
|
|
322
285
|
if (this.win32) {
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
const { root: pRoot } = path.win32.parse(entry.path);
|
|
286
|
+
const aRoot = win32Root(absolute);
|
|
287
|
+
absolute = aRoot + wc.encode(absolute.slice(aRoot.length));
|
|
288
|
+
const pRoot = win32Root(entry.path);
|
|
327
289
|
entry.path = pRoot + wc.encode(entry.path.slice(pRoot.length));
|
|
328
290
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
// eslint-disable-next-line no-fallthrough
|
|
343
|
-
case 'File':
|
|
344
|
-
case 'OldFile':
|
|
345
|
-
case 'ContiguousFile':
|
|
346
|
-
case 'Link':
|
|
347
|
-
case 'SymbolicLink':
|
|
348
|
-
return this[CHECKFS](entry);
|
|
349
|
-
case 'CharacterDevice':
|
|
350
|
-
case 'BlockDevice':
|
|
351
|
-
case 'FIFO':
|
|
352
|
-
default:
|
|
353
|
-
return this[UNSUPPORTED](entry);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
[ONERROR](er, entry) {
|
|
357
|
-
// Cwd has to exist, or else nothing works. That's serious.
|
|
358
|
-
// Other errors are warnings, which raise the error in strict
|
|
359
|
-
// mode, but otherwise continue on.
|
|
360
|
-
if (er.name === 'CwdError') {
|
|
361
|
-
this.emit('error', er);
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
this.warn('TAR_ENTRY_ERROR', er, { entry });
|
|
365
|
-
this[UNPEND]();
|
|
366
|
-
entry.resume();
|
|
291
|
+
entry.absolute = absolute;
|
|
292
|
+
// Never set the setuid, setgid, or sticky bit from an archive.
|
|
293
|
+
if (typeof entry.mode === 'number')
|
|
294
|
+
entry.mode &= 0o777;
|
|
295
|
+
if (dirTypes.has(entry.type)) {
|
|
296
|
+
if (entry.mode)
|
|
297
|
+
entry.mode |= 0o700;
|
|
298
|
+
}
|
|
299
|
+
else if (!fileTypes.has(entry.type) && !linkTypes.has(entry.type)) {
|
|
300
|
+
// A device or a FIFO is never made.
|
|
301
|
+
entry.unsupported = true;
|
|
302
|
+
this.warn('TAR_ENTRY_UNSUPPORTED', `unsupported entry type: ${entry.type}`, { entry });
|
|
303
|
+
return false;
|
|
367
304
|
}
|
|
305
|
+
return true;
|
|
368
306
|
}
|
|
369
|
-
|
|
370
|
-
|
|
307
|
+
/**
|
|
308
|
+
* The paths that the entry must have for itself while it is made.
|
|
309
|
+
* A link also reserves its target, so that an entry that makes the
|
|
310
|
+
* target, and an entry that goes through the link, do not run at
|
|
311
|
+
* the same time as the link.
|
|
312
|
+
*/
|
|
313
|
+
reservedPaths(entry) {
|
|
314
|
+
const { path, linkpath } = entry;
|
|
315
|
+
if (!linkpath)
|
|
316
|
+
return [path];
|
|
317
|
+
// The target of a symlink is relative to the directory of the
|
|
318
|
+
// link. The target of a hard link is relative to the cwd.
|
|
319
|
+
return [
|
|
320
|
+
path,
|
|
321
|
+
entry.type === 'SymbolicLink' && !isAbsolute(linkpath) ?
|
|
322
|
+
join(dirname(path), linkpath)
|
|
323
|
+
: linkpath,
|
|
324
|
+
];
|
|
325
|
+
}
|
|
326
|
+
/** The options to make a directory with a mode. */
|
|
327
|
+
mkdirOptions(mode) {
|
|
328
|
+
return {
|
|
371
329
|
uid: this.uid,
|
|
372
330
|
gid: this.gid,
|
|
373
331
|
processUid: this.processUid,
|
|
@@ -376,516 +334,615 @@ export class Unpack extends Parser {
|
|
|
376
334
|
preserve: this.preservePaths,
|
|
377
335
|
unlink: this.unlink,
|
|
378
336
|
cwd: this.cwd,
|
|
379
|
-
mode
|
|
380
|
-
}
|
|
337
|
+
mode,
|
|
338
|
+
};
|
|
381
339
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
340
|
+
/**
|
|
341
|
+
* The owner to set on the entry, if it needs one: with
|
|
342
|
+
* `preserveOwner`, when the owner in the archive is not the process
|
|
343
|
+
* owner, and with `uid` and `gid`, when they are not the process
|
|
344
|
+
* owner.
|
|
345
|
+
*/
|
|
346
|
+
owner(entry) {
|
|
347
|
+
const doChown = this.forceChown ||
|
|
386
348
|
(this.preserveOwner &&
|
|
387
349
|
((typeof entry.uid === 'number' &&
|
|
388
350
|
entry.uid !== this.processUid) ||
|
|
389
351
|
(typeof entry.gid === 'number' &&
|
|
390
352
|
entry.gid !== this.processGid))) ||
|
|
391
353
|
(typeof this.uid === 'number' && this.uid !== this.processUid) ||
|
|
392
|
-
(typeof this.gid === 'number' && this.gid !== this.processGid)
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
354
|
+
(typeof this.gid === 'number' && this.gid !== this.processGid);
|
|
355
|
+
const uid = uint32(this.uid, entry.uid, this.processUid);
|
|
356
|
+
const gid = uint32(this.gid, entry.gid, this.processGid);
|
|
357
|
+
return doChown && typeof uid === 'number' && typeof gid === 'number' ?
|
|
358
|
+
{ uid, gid }
|
|
359
|
+
: undefined;
|
|
360
|
+
}
|
|
361
|
+
/** The times to set on the entry, if it needs them. */
|
|
362
|
+
times(entry) {
|
|
363
|
+
return entry.mtime && !this.noMtime ?
|
|
364
|
+
{ atime: entry.atime || new Date(), mtime: entry.mtime }
|
|
365
|
+
: undefined;
|
|
366
|
+
}
|
|
367
|
+
/** True if the object on disk at the path of the entry must stay. */
|
|
368
|
+
skip(entry, st) {
|
|
369
|
+
return (this.keep || (this.newer && st.mtime > (entry.mtime ?? st.mtime)));
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* True if the entry can be written into the file that is on disk.
|
|
373
|
+
* A file with more than one link is not used, because the write
|
|
374
|
+
* would change the other links. Windows does not report a useful
|
|
375
|
+
* link count.
|
|
376
|
+
*/
|
|
377
|
+
isReusable(entry, st) {
|
|
378
|
+
return (entry.type === 'File' &&
|
|
379
|
+
!this.unlink &&
|
|
380
|
+
st.isFile() &&
|
|
381
|
+
st.nlink <= 1 &&
|
|
382
|
+
!this.win32);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* The parts of the path from the extraction directory to the
|
|
386
|
+
* target of a link entry. None of them can be a symbolic link.
|
|
387
|
+
*/
|
|
388
|
+
linkParts(entry, absolute) {
|
|
389
|
+
const linkpath = String(entry.linkpath);
|
|
390
|
+
return entry.type === 'Link' ?
|
|
391
|
+
linkpath.split('/')
|
|
392
|
+
: relative(this.cwd, this.resolve(this.dirname(absolute), linkpath)).split('/');
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* The parts of the path from the extraction directory to the
|
|
396
|
+
* parent directory of an entry. The extraction checks them again
|
|
397
|
+
* after it makes the entry: none of them can be a symbolic link
|
|
398
|
+
* then. So a directory that another process replaced with a
|
|
399
|
+
* symbolic link during the extraction is an error of the entry.
|
|
400
|
+
*/
|
|
401
|
+
parentParts(absolute) {
|
|
402
|
+
const { cwd } = this;
|
|
403
|
+
const parent = absolute === cwd ? cwd : this.dirname(absolute);
|
|
404
|
+
return parent === cwd ? [] : relative(cwd, parent).split('/');
|
|
405
|
+
}
|
|
406
|
+
/** The error for a link target that goes through a symbolic link. */
|
|
407
|
+
symlinkError(symlink, parts) {
|
|
408
|
+
return new SymlinkError(symlink, this.resolve(this.cwd, parts.join('/')));
|
|
399
409
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
410
|
+
}
|
|
411
|
+
// Unlinks on Windows are not atomic. A file that is made at the path
|
|
412
|
+
// of a file that was just removed can be removed with it. So rename
|
|
413
|
+
// the file first, and then remove it under the new name.
|
|
414
|
+
const deleteName = (path) => path +
|
|
415
|
+
'.DELETE.' +
|
|
416
|
+
Array.from(crypto.getRandomValues(new Uint8Array(16)), b => b.toString(16).padStart(2, '0')).join('');
|
|
417
|
+
/**
|
|
418
|
+
* Extracts the entries of an archive with async file system
|
|
419
|
+
* functions.
|
|
420
|
+
*
|
|
421
|
+
* Several entries are extracted at one time. Entries that use the
|
|
422
|
+
* same path, or a path and a directory above it, are extracted in
|
|
423
|
+
* the order of the archive.
|
|
424
|
+
*/
|
|
425
|
+
export class Unpack extends UnpackBase {
|
|
426
|
+
#fs;
|
|
427
|
+
#reservations;
|
|
428
|
+
#jobs;
|
|
429
|
+
// the number of entries that are in work
|
|
430
|
+
#active = 0;
|
|
431
|
+
#wake;
|
|
432
|
+
#checkedCwd = false;
|
|
433
|
+
#cwdCheck;
|
|
434
|
+
constructor(opt) {
|
|
435
|
+
super(opt);
|
|
436
|
+
this.#fs = this.opt.fs;
|
|
437
|
+
this.#reservations = new PathReservations(this.win32);
|
|
438
|
+
this.#jobs = countOption('jobs', this.opt.jobs, DEFAULT_JOBS);
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Extract the archive. The promise settles when all the file
|
|
442
|
+
* system work is done. It rejects with the first error that stops
|
|
443
|
+
* the extraction.
|
|
444
|
+
*/
|
|
445
|
+
async extract(input) {
|
|
446
|
+
const reader = new TarReader(input, this.readerOptions());
|
|
447
|
+
const { onEntry } = this.opt;
|
|
448
|
+
const stream = !!this.opt.transform;
|
|
449
|
+
try {
|
|
450
|
+
while (!this.fatal) {
|
|
451
|
+
const entry = reader.poll();
|
|
452
|
+
if (entry === null)
|
|
453
|
+
break;
|
|
454
|
+
if (entry === undefined) {
|
|
455
|
+
await reader.fill();
|
|
456
|
+
continue;
|
|
425
457
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
458
|
+
if (onEntry)
|
|
459
|
+
await onEntry(entry);
|
|
460
|
+
// The caller took the content, so there is nothing to write.
|
|
461
|
+
if (entry.bodyUsed)
|
|
462
|
+
continue;
|
|
463
|
+
if (!this.check(entry))
|
|
464
|
+
continue;
|
|
465
|
+
// A file whose content is all in memory is written while the
|
|
466
|
+
// next entries are read. Other files are written as their
|
|
467
|
+
// content arrives.
|
|
468
|
+
const body = [];
|
|
469
|
+
let inMemory = !stream;
|
|
470
|
+
if (inMemory && fileTypes.has(entry.type)) {
|
|
471
|
+
for (;;) {
|
|
472
|
+
const part = reader.readBody(entry);
|
|
473
|
+
if (part === null)
|
|
474
|
+
break;
|
|
475
|
+
if (part === undefined) {
|
|
476
|
+
inMemory = false;
|
|
477
|
+
break;
|
|
436
478
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
}
|
|
440
|
-
fullyDone();
|
|
441
|
-
});
|
|
479
|
+
body.push(part);
|
|
480
|
+
}
|
|
442
481
|
}
|
|
482
|
+
const work = this.#start(entry, body, inMemory ? undefined : reader);
|
|
483
|
+
if (!inMemory)
|
|
484
|
+
await work;
|
|
485
|
+
while (this.#active >= this.#jobs)
|
|
486
|
+
await this.#idle();
|
|
443
487
|
}
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
fs.futimes(fd, atime, mtime, er => er ?
|
|
456
|
-
fs.utimes(abs, atime, mtime, er2 => done(er2 && er))
|
|
457
|
-
: done());
|
|
458
|
-
}
|
|
459
|
-
if (typeof fd === 'number' && this[DOCHOWN](entry)) {
|
|
460
|
-
actions++;
|
|
461
|
-
const uid = this[UID](entry);
|
|
462
|
-
const gid = this[GID](entry);
|
|
463
|
-
if (typeof uid === 'number' && typeof gid === 'number') {
|
|
464
|
-
fs.fchown(fd, uid, gid, er => er ? fs.chown(abs, uid, gid, er2 => done(er2 && er)) : done());
|
|
465
|
-
}
|
|
488
|
+
}
|
|
489
|
+
catch (er) {
|
|
490
|
+
this.fail(er);
|
|
491
|
+
}
|
|
492
|
+
await reader.return().catch(er => this.fail(er));
|
|
493
|
+
while (this.#active > 0)
|
|
494
|
+
await this.#idle();
|
|
495
|
+
if (this.fatal) {
|
|
496
|
+
const { error } = this.fatal;
|
|
497
|
+
if (error && typeof error === 'object' && 'tarCode' in error) {
|
|
498
|
+
Object.assign(error, { cwd: this.cwd });
|
|
466
499
|
}
|
|
467
|
-
|
|
468
|
-
});
|
|
469
|
-
const tx = this.transform ? this.transform(entry) || entry : entry;
|
|
470
|
-
if (tx !== entry) {
|
|
471
|
-
tx.on('error', er => {
|
|
472
|
-
this[ONERROR](er, entry);
|
|
473
|
-
fullyDone();
|
|
474
|
-
});
|
|
475
|
-
entry.pipe(tx);
|
|
500
|
+
throw error;
|
|
476
501
|
}
|
|
477
|
-
tx.pipe(stream);
|
|
478
502
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
503
|
+
// Resolves when an entry that is in work is done.
|
|
504
|
+
#idle() {
|
|
505
|
+
return new Promise(res => {
|
|
506
|
+
this.#wake = res;
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
// Extract the entry when its paths are free. The promise never
|
|
510
|
+
// rejects: a failure is a warning, or it sets `fatal`.
|
|
511
|
+
#start(entry, body, reader) {
|
|
512
|
+
this.#active++;
|
|
513
|
+
return this.#reservations.reserve(this.reservedPaths(entry), async () => {
|
|
514
|
+
try {
|
|
515
|
+
if (!this.fatal)
|
|
516
|
+
await this.#extract(entry, body, reader);
|
|
486
517
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
518
|
+
catch (er) {
|
|
519
|
+
try {
|
|
520
|
+
this.entryError(er, entry);
|
|
521
|
+
}
|
|
522
|
+
catch (fatal) {
|
|
523
|
+
this.fail(fatal);
|
|
493
524
|
}
|
|
494
|
-
};
|
|
495
|
-
if (entry.mtime && !this.noMtime) {
|
|
496
|
-
actions++;
|
|
497
|
-
fs.utimes(String(entry.absolute), entry.atime || new Date(), entry.mtime, done);
|
|
498
|
-
}
|
|
499
|
-
if (this[DOCHOWN](entry)) {
|
|
500
|
-
actions++;
|
|
501
|
-
fs.chown(String(entry.absolute), Number(this[UID](entry)), Number(this[GID](entry)), done);
|
|
502
525
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
[UNSUPPORTED](entry) {
|
|
507
|
-
entry.unsupported = true;
|
|
508
|
-
this.warn('TAR_ENTRY_UNSUPPORTED', `unsupported entry type: ${entry.type}`, { entry });
|
|
509
|
-
entry.resume();
|
|
510
|
-
}
|
|
511
|
-
[SYMLINK](entry, done) {
|
|
512
|
-
const parts = normalizeWindowsPath(path.relative(this.cwd, path.resolve(path.dirname(String(entry.absolute)), String(entry.linkpath)))).split('/');
|
|
513
|
-
this[ENSURE_NO_SYMLINK](entry, this.cwd, parts, () => this[LINK](entry, String(entry.linkpath), 'symlink', done), er => {
|
|
514
|
-
this[ONERROR](er, entry);
|
|
515
|
-
done();
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
[HARDLINK](entry, done) {
|
|
519
|
-
const linkpath = normalizeWindowsPath(path.resolve(this.cwd, String(entry.linkpath)));
|
|
520
|
-
const parts = normalizeWindowsPath(String(entry.linkpath)).split('/');
|
|
521
|
-
this[ENSURE_NO_SYMLINK](entry, this.cwd, parts, () => this[LINK](entry, linkpath, 'link', done), er => {
|
|
522
|
-
this[ONERROR](er, entry);
|
|
523
|
-
done();
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
[ENSURE_NO_SYMLINK](entry, cwd, parts, done, onError) {
|
|
527
|
-
const p = parts.shift();
|
|
528
|
-
if (this.preservePaths || p === undefined)
|
|
529
|
-
return done();
|
|
530
|
-
const t = path.resolve(cwd, p);
|
|
531
|
-
fs.lstat(t, (er, st) => {
|
|
532
|
-
if (er)
|
|
533
|
-
return done();
|
|
534
|
-
if (st?.isSymbolicLink()) {
|
|
535
|
-
return onError(new SymlinkError(t, path.resolve(t, parts.join('/'))));
|
|
536
|
-
}
|
|
537
|
-
this[ENSURE_NO_SYMLINK](entry, t, parts, done, onError);
|
|
526
|
+
this.#active--;
|
|
527
|
+
this.#wake?.();
|
|
538
528
|
});
|
|
539
529
|
}
|
|
540
|
-
|
|
541
|
-
this
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
530
|
+
#mkdir(dir, mode) {
|
|
531
|
+
return mkdir(this.#fs, dir, this.mkdirOptions(mode));
|
|
532
|
+
}
|
|
533
|
+
// The extraction directory must exist. Entries that start at the
|
|
534
|
+
// same time share one check.
|
|
535
|
+
#checkCwd() {
|
|
536
|
+
return (this.#cwdCheck ??= this.#mkdir(this.cwd, this.dmode).then(() => {
|
|
537
|
+
this.#checkedCwd = true;
|
|
538
|
+
}, er => {
|
|
539
|
+
this.#cwdCheck = undefined;
|
|
540
|
+
throw er;
|
|
541
|
+
}));
|
|
542
|
+
}
|
|
543
|
+
async #extract(entry, body, reader) {
|
|
544
|
+
const fs = this.#fs;
|
|
545
|
+
const absolute = entry.absolute;
|
|
546
|
+
const { cwd } = this;
|
|
547
|
+
if (!this.#checkedCwd)
|
|
548
|
+
await this.#checkCwd();
|
|
549
|
+
if (absolute !== cwd) {
|
|
550
|
+
const parent = this.dirname(absolute);
|
|
551
|
+
if (parent !== cwd)
|
|
552
|
+
await this.#mkdir(parent, this.dmode);
|
|
553
|
+
}
|
|
554
|
+
// Remove what is at the path, if the entry cannot use it.
|
|
555
|
+
const st = await fs.lstat(absolute).catch(() => undefined);
|
|
556
|
+
if (st && this.skip(entry, st))
|
|
557
|
+
return;
|
|
558
|
+
if (st && !this.isReusable(entry, st)) {
|
|
559
|
+
if (st.isDirectory() && dirTypes.has(entry.type)) {
|
|
560
|
+
if (this.chmod &&
|
|
561
|
+
entry.mode &&
|
|
562
|
+
(st.mode & 0o7777) !== entry.mode) {
|
|
563
|
+
await fs.chmod(absolute, entry.mode);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
else if (absolute !== cwd) {
|
|
567
|
+
if (st.isDirectory())
|
|
568
|
+
await fs.rmdir(absolute);
|
|
569
|
+
else
|
|
570
|
+
await this.#unlink(absolute);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
if (fileTypes.has(entry.type)) {
|
|
574
|
+
return this.#file(entry, absolute, body, reader);
|
|
575
|
+
}
|
|
576
|
+
if (dirTypes.has(entry.type))
|
|
577
|
+
await this.#directory(entry, absolute);
|
|
578
|
+
else {
|
|
579
|
+
await this.#ensureNoSymlink(this.linkParts(entry, absolute));
|
|
580
|
+
const linkpath = String(entry.linkpath);
|
|
581
|
+
if (entry.type === 'Link') {
|
|
582
|
+
await fs.link(this.resolve(cwd, linkpath), absolute);
|
|
583
|
+
}
|
|
584
|
+
else {
|
|
585
|
+
await fs.symlink(linkpath, absolute);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
await this.#ensureNoSymlink(this.parentParts(absolute));
|
|
546
589
|
}
|
|
547
|
-
|
|
548
|
-
this
|
|
549
|
-
|
|
590
|
+
async #unlink(path) {
|
|
591
|
+
const fs = this.#fs;
|
|
592
|
+
if (!this.win32)
|
|
593
|
+
return fs.unlink(path);
|
|
594
|
+
const name = deleteName(path);
|
|
595
|
+
await fs.rename(path, name);
|
|
596
|
+
await fs.unlink(name);
|
|
550
597
|
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
st.
|
|
558
|
-
st
|
|
559
|
-
|
|
598
|
+
async #ensureNoSymlink(parts) {
|
|
599
|
+
if (this.preservePaths)
|
|
600
|
+
return;
|
|
601
|
+
let t = this.cwd;
|
|
602
|
+
for (const p of parts) {
|
|
603
|
+
t = this.resolve(t, p);
|
|
604
|
+
const st = await this.#fs.lstat(t).catch(() => undefined);
|
|
605
|
+
if (!st)
|
|
606
|
+
return;
|
|
607
|
+
if (st.isSymbolicLink())
|
|
608
|
+
throw this.symlinkError(t, parts);
|
|
609
|
+
}
|
|
560
610
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
this
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
611
|
+
async #directory(entry, absolute) {
|
|
612
|
+
const fs = this.#fs;
|
|
613
|
+
await this.#mkdir(absolute, entry.mode ?? this.dmode);
|
|
614
|
+
// These do not follow a symbolic link that replaced the
|
|
615
|
+
// directory. A failure is not an error of the entry.
|
|
616
|
+
const times = this.times(entry);
|
|
617
|
+
if (times) {
|
|
618
|
+
await fs.lutimes(absolute, times.atime, times.mtime).catch(() => { });
|
|
619
|
+
}
|
|
620
|
+
const owner = this.owner(entry);
|
|
621
|
+
if (owner) {
|
|
622
|
+
await fs.lchown(absolute, owner.uid, owner.gid).catch(() => { });
|
|
567
623
|
}
|
|
568
|
-
this.reservations.reserve(paths, done => this[CHECKFS2](entry, done));
|
|
569
624
|
}
|
|
570
|
-
|
|
571
|
-
const
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
625
|
+
async #file(entry, absolute, body, reader) {
|
|
626
|
+
const fs = this.#fs;
|
|
627
|
+
const handle = await fs.open(absolute, this.writeFlag(entry.size), entry.mode ?? this.fmode);
|
|
628
|
+
try {
|
|
629
|
+
// The file is open. Write to it only if no parent directory
|
|
630
|
+
// became a symbolic link before the open.
|
|
631
|
+
await this.#ensureNoSymlink(this.parentParts(absolute));
|
|
632
|
+
if (reader)
|
|
633
|
+
await this.#pipe(entry, body, reader, handle);
|
|
634
|
+
else
|
|
635
|
+
for (const part of body)
|
|
636
|
+
await handle.write(part);
|
|
637
|
+
// Use the open file, so that a symbolic link that replaced the
|
|
638
|
+
// path is not followed. If that fails, use the path.
|
|
639
|
+
const times = this.times(entry);
|
|
640
|
+
if (times) {
|
|
641
|
+
const { atime, mtime } = times;
|
|
642
|
+
await handle.utimes(atime, mtime).catch(async (er) => {
|
|
643
|
+
await fs.utimes(absolute, atime, mtime).catch(() => {
|
|
644
|
+
throw er;
|
|
645
|
+
});
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
const owner = this.owner(entry);
|
|
649
|
+
if (owner) {
|
|
650
|
+
const { uid, gid } = owner;
|
|
651
|
+
await handle.chown(uid, gid).catch(async (er) => {
|
|
652
|
+
await fs.chown(absolute, uid, gid).catch(() => {
|
|
653
|
+
throw er;
|
|
654
|
+
});
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
catch (er) {
|
|
659
|
+
await handle.close().catch(() => { });
|
|
660
|
+
throw er;
|
|
661
|
+
}
|
|
662
|
+
await handle.close();
|
|
663
|
+
}
|
|
664
|
+
// Write the content of the entry as it arrives, through the
|
|
665
|
+
// transform stream if there is one.
|
|
666
|
+
async #pipe(entry, body, reader, handle) {
|
|
667
|
+
let i = 0;
|
|
668
|
+
const next = async () => {
|
|
669
|
+
if (i < body.length)
|
|
670
|
+
return body[i++];
|
|
671
|
+
try {
|
|
672
|
+
for (;;) {
|
|
673
|
+
const part = reader.readBody(entry);
|
|
674
|
+
if (part !== undefined)
|
|
675
|
+
return part;
|
|
676
|
+
await reader.fill();
|
|
580
677
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
678
|
+
}
|
|
679
|
+
catch (er) {
|
|
680
|
+
// The archive cannot be read.
|
|
681
|
+
throw this.fail(er);
|
|
682
|
+
}
|
|
584
683
|
};
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
684
|
+
const tx = this.opt.transform?.(entry);
|
|
685
|
+
if (!tx) {
|
|
686
|
+
// Write one part while the next part is read.
|
|
687
|
+
let writing;
|
|
688
|
+
let failed;
|
|
689
|
+
try {
|
|
690
|
+
for (let part; (part = await next());) {
|
|
691
|
+
await writing;
|
|
692
|
+
if (failed)
|
|
693
|
+
break;
|
|
694
|
+
writing = handle.write(part).then(() => { }, error => {
|
|
695
|
+
failed = { error };
|
|
596
696
|
});
|
|
597
697
|
}
|
|
598
698
|
}
|
|
599
|
-
|
|
699
|
+
finally {
|
|
700
|
+
await writing;
|
|
701
|
+
}
|
|
702
|
+
if (failed)
|
|
703
|
+
throw failed.error;
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
const writer = tx.writable.getWriter();
|
|
707
|
+
const out = tx.readable.getReader();
|
|
708
|
+
let failed;
|
|
709
|
+
// Stop the two streams. A read that waits gets the end of the
|
|
710
|
+
// stream, and a write that waits fails.
|
|
711
|
+
const stop = async (error) => {
|
|
712
|
+
failed ??= { error };
|
|
713
|
+
await out.cancel(error).catch(() => { });
|
|
714
|
+
await writer.abort(error).catch(() => { });
|
|
600
715
|
};
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
(
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
}
|
|
614
|
-
if (
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
716
|
+
const feed = (async () => {
|
|
717
|
+
try {
|
|
718
|
+
for (let part; (part = await next());)
|
|
719
|
+
await writer.write(part);
|
|
720
|
+
await writer.close();
|
|
721
|
+
}
|
|
722
|
+
catch (er) {
|
|
723
|
+
await stop(er);
|
|
724
|
+
}
|
|
725
|
+
})();
|
|
726
|
+
try {
|
|
727
|
+
for (;;) {
|
|
728
|
+
const { done, value } = await out.read();
|
|
729
|
+
if (done)
|
|
730
|
+
break;
|
|
731
|
+
await handle.write(value);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
catch (er) {
|
|
735
|
+
await stop(er);
|
|
736
|
+
}
|
|
737
|
+
// The feed reads the archive, so it must end before the next
|
|
738
|
+
// entry is read.
|
|
739
|
+
await feed;
|
|
740
|
+
if (failed)
|
|
741
|
+
throw failed.error;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Extracts the entries of an archive with sync file system
|
|
746
|
+
* functions, one entry at a time.
|
|
747
|
+
*/
|
|
748
|
+
export class UnpackSync extends UnpackBase {
|
|
749
|
+
#fs;
|
|
750
|
+
#checkedCwd = false;
|
|
751
|
+
constructor(opt) {
|
|
752
|
+
super(opt);
|
|
753
|
+
this.#fs = this.opt.fs;
|
|
754
|
+
}
|
|
755
|
+
/** Extract the archive. Throws the first error that stops it. */
|
|
756
|
+
extract(input) {
|
|
757
|
+
const reader = new TarReaderSync(input, this.readerOptions());
|
|
758
|
+
const { onEntry } = this.opt;
|
|
759
|
+
try {
|
|
760
|
+
for (const entry of reader) {
|
|
761
|
+
onEntry?.(entry);
|
|
762
|
+
if (entry.bodyUsed)
|
|
763
|
+
continue;
|
|
764
|
+
if (!this.check(entry))
|
|
765
|
+
continue;
|
|
766
|
+
try {
|
|
767
|
+
this.#extract(entry, reader);
|
|
633
768
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
if (entry.absolute === this.cwd) {
|
|
637
|
-
return this[MAKEFS](null, entry, done);
|
|
769
|
+
catch (er) {
|
|
770
|
+
this.entryError(er, entry);
|
|
638
771
|
}
|
|
639
|
-
|
|
640
|
-
});
|
|
641
|
-
};
|
|
642
|
-
if (this[CHECKED_CWD]) {
|
|
643
|
-
start();
|
|
772
|
+
}
|
|
644
773
|
}
|
|
645
|
-
|
|
646
|
-
|
|
774
|
+
catch (error) {
|
|
775
|
+
if (error && typeof error === 'object' && 'tarCode' in error) {
|
|
776
|
+
Object.assign(error, { cwd: this.cwd });
|
|
777
|
+
}
|
|
778
|
+
throw error;
|
|
647
779
|
}
|
|
648
780
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
781
|
+
#mkdir(dir, mode) {
|
|
782
|
+
mkdirSync(this.#fs, dir, this.mkdirOptions(mode));
|
|
783
|
+
}
|
|
784
|
+
#extract(entry, reader) {
|
|
785
|
+
const fs = this.#fs;
|
|
786
|
+
const absolute = entry.absolute;
|
|
787
|
+
const { cwd } = this;
|
|
788
|
+
if (!this.#checkedCwd) {
|
|
789
|
+
this.#mkdir(cwd, this.dmode);
|
|
790
|
+
this.#checkedCwd = true;
|
|
791
|
+
}
|
|
792
|
+
if (absolute !== cwd) {
|
|
793
|
+
const parent = this.dirname(absolute);
|
|
794
|
+
if (parent !== cwd)
|
|
795
|
+
this.#mkdir(parent, this.dmode);
|
|
796
|
+
}
|
|
797
|
+
// Remove what is at the path, if the entry cannot use it.
|
|
798
|
+
let st;
|
|
799
|
+
try {
|
|
800
|
+
st = fs.lstatSync(absolute);
|
|
801
|
+
}
|
|
802
|
+
catch { }
|
|
803
|
+
if (st && this.skip(entry, st))
|
|
653
804
|
return;
|
|
805
|
+
if (st && !this.isReusable(entry, st)) {
|
|
806
|
+
if (st.isDirectory() && dirTypes.has(entry.type)) {
|
|
807
|
+
if (this.chmod &&
|
|
808
|
+
entry.mode &&
|
|
809
|
+
(st.mode & 0o7777) !== entry.mode) {
|
|
810
|
+
fs.chmodSync(absolute, entry.mode);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
else if (absolute !== cwd) {
|
|
814
|
+
if (st.isDirectory())
|
|
815
|
+
fs.rmdirSync(absolute);
|
|
816
|
+
else
|
|
817
|
+
this.#unlink(absolute);
|
|
818
|
+
}
|
|
654
819
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
case 'GNUDumpDir':
|
|
666
|
-
return this[DIRECTORY](entry, done);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
[LINK](entry, linkpath, link, done) {
|
|
670
|
-
fs[link](linkpath, String(entry.absolute), er => {
|
|
671
|
-
if (er) {
|
|
672
|
-
this[ONERROR](er, entry);
|
|
820
|
+
if (fileTypes.has(entry.type)) {
|
|
821
|
+
return this.#file(entry, absolute, reader);
|
|
822
|
+
}
|
|
823
|
+
if (dirTypes.has(entry.type))
|
|
824
|
+
this.#directory(entry, absolute);
|
|
825
|
+
else {
|
|
826
|
+
this.#ensureNoSymlink(this.linkParts(entry, absolute));
|
|
827
|
+
const linkpath = String(entry.linkpath);
|
|
828
|
+
if (entry.type === 'Link') {
|
|
829
|
+
fs.linkSync(this.resolve(cwd, linkpath), absolute);
|
|
673
830
|
}
|
|
674
831
|
else {
|
|
675
|
-
|
|
676
|
-
entry.resume();
|
|
677
|
-
}
|
|
678
|
-
done();
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
const callSync = (fn) => {
|
|
683
|
-
try {
|
|
684
|
-
return [null, fn()];
|
|
685
|
-
}
|
|
686
|
-
catch (er) {
|
|
687
|
-
return [er, null];
|
|
688
|
-
}
|
|
689
|
-
};
|
|
690
|
-
export class UnpackSync extends Unpack {
|
|
691
|
-
sync = true;
|
|
692
|
-
[MAKEFS](er, entry) {
|
|
693
|
-
return super[MAKEFS](er, entry, () => { });
|
|
694
|
-
}
|
|
695
|
-
[CHECKFS](entry) {
|
|
696
|
-
if (!this[CHECKED_CWD]) {
|
|
697
|
-
const er = this[MKDIR](this.cwd, this.dmode);
|
|
698
|
-
if (er) {
|
|
699
|
-
return this[ONERROR](er, entry);
|
|
700
|
-
}
|
|
701
|
-
this[CHECKED_CWD] = true;
|
|
702
|
-
}
|
|
703
|
-
// don't bother to make the parent if the current entry is the cwd,
|
|
704
|
-
// we've already checked it.
|
|
705
|
-
if (entry.absolute !== this.cwd) {
|
|
706
|
-
const parent = normalizeWindowsPath(path.dirname(String(entry.absolute)));
|
|
707
|
-
if (parent !== this.cwd) {
|
|
708
|
-
const mkParent = this[MKDIR](parent, this.dmode);
|
|
709
|
-
if (mkParent) {
|
|
710
|
-
return this[ONERROR](mkParent, entry);
|
|
711
|
-
}
|
|
832
|
+
fs.symlinkSync(linkpath, absolute);
|
|
712
833
|
}
|
|
713
834
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
return
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
: [];
|
|
732
|
-
return this[MAKEFS](er, entry);
|
|
733
|
-
}
|
|
734
|
-
// not a dir entry, have to remove it
|
|
735
|
-
const [er] = callSync(() => fs.rmdirSync(String(entry.absolute)));
|
|
736
|
-
this[MAKEFS](er, entry);
|
|
737
|
-
}
|
|
738
|
-
// not a dir, and not reusable.
|
|
739
|
-
// don't remove if it's the cwd, since we want that error.
|
|
740
|
-
const [er] = entry.absolute === this.cwd ?
|
|
741
|
-
[]
|
|
742
|
-
: callSync(() => unlinkFileSync(String(entry.absolute)));
|
|
743
|
-
this[MAKEFS](er, entry);
|
|
744
|
-
}
|
|
745
|
-
[FILE](entry, done) {
|
|
746
|
-
const mode = typeof entry.mode === 'number' ? entry.mode & 0o7777 : this.fmode;
|
|
747
|
-
const oner = (er) => {
|
|
748
|
-
let closeError;
|
|
835
|
+
this.#ensureNoSymlink(this.parentParts(absolute));
|
|
836
|
+
}
|
|
837
|
+
#unlink(path) {
|
|
838
|
+
const fs = this.#fs;
|
|
839
|
+
if (!this.win32)
|
|
840
|
+
return fs.unlinkSync(path);
|
|
841
|
+
const name = deleteName(path);
|
|
842
|
+
fs.renameSync(path, name);
|
|
843
|
+
fs.unlinkSync(name);
|
|
844
|
+
}
|
|
845
|
+
#ensureNoSymlink(parts) {
|
|
846
|
+
if (this.preservePaths)
|
|
847
|
+
return;
|
|
848
|
+
let t = this.cwd;
|
|
849
|
+
for (const p of parts) {
|
|
850
|
+
t = this.resolve(t, p);
|
|
851
|
+
let st;
|
|
749
852
|
try {
|
|
750
|
-
fs.
|
|
751
|
-
}
|
|
752
|
-
catch (e) {
|
|
753
|
-
closeError = e;
|
|
853
|
+
st = this.#fs.lstatSync(t);
|
|
754
854
|
}
|
|
755
|
-
|
|
756
|
-
|
|
855
|
+
catch {
|
|
856
|
+
return;
|
|
757
857
|
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
let fd;
|
|
761
|
-
try {
|
|
762
|
-
fd = fs.openSync(String(entry.absolute), getWriteFlag(entry.size), mode);
|
|
763
|
-
/* c8 ignore start - This is only a problem if the file was successfully
|
|
764
|
-
* statted, BUT failed to open. Testing this is annoying, and we
|
|
765
|
-
* already have ample testint for other uses of oner() methods.
|
|
766
|
-
*/
|
|
858
|
+
if (st.isSymbolicLink())
|
|
859
|
+
throw this.symlinkError(t, parts);
|
|
767
860
|
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
861
|
+
}
|
|
862
|
+
#directory(entry, absolute) {
|
|
863
|
+
const fs = this.#fs;
|
|
864
|
+
this.#mkdir(absolute, entry.mode ?? this.dmode);
|
|
865
|
+
// These do not follow a symbolic link that replaced the
|
|
866
|
+
// directory. A failure is not an error of the entry.
|
|
867
|
+
const times = this.times(entry);
|
|
868
|
+
if (times) {
|
|
869
|
+
try {
|
|
870
|
+
fs.lutimesSync(absolute, times.atime, times.mtime);
|
|
871
|
+
}
|
|
872
|
+
catch { }
|
|
776
873
|
}
|
|
777
|
-
|
|
874
|
+
const owner = this.owner(entry);
|
|
875
|
+
if (owner) {
|
|
778
876
|
try {
|
|
779
|
-
fs.
|
|
877
|
+
fs.lchownSync(absolute, owner.uid, owner.gid);
|
|
780
878
|
}
|
|
781
|
-
catch
|
|
782
|
-
|
|
879
|
+
catch { }
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
#file(entry, absolute, reader) {
|
|
883
|
+
const fs = this.#fs;
|
|
884
|
+
const fd = fs.openSync(absolute, this.writeFlag(entry.size), entry.mode ?? this.fmode);
|
|
885
|
+
try {
|
|
886
|
+
// The file is open. Write to it only if no parent directory
|
|
887
|
+
// became a symbolic link before the open.
|
|
888
|
+
this.#ensureNoSymlink(this.parentParts(absolute));
|
|
889
|
+
const tx = this.opt.transform?.(entry);
|
|
890
|
+
for (;;) {
|
|
891
|
+
let part;
|
|
892
|
+
try {
|
|
893
|
+
part = reader.readBody(entry);
|
|
894
|
+
}
|
|
895
|
+
catch (er) {
|
|
896
|
+
// The archive cannot be read.
|
|
897
|
+
throw this.fail(er);
|
|
898
|
+
}
|
|
899
|
+
if (!part)
|
|
900
|
+
break;
|
|
901
|
+
fs.writeSync(fd, tx ? tx(part) : part);
|
|
783
902
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
if (entry.mtime && !this.noMtime) {
|
|
790
|
-
const atime = entry.atime || new Date();
|
|
791
|
-
const mtime = entry.mtime;
|
|
903
|
+
// Use the open file, so that a symbolic link that replaced the
|
|
904
|
+
// path is not followed. If that fails, use the path.
|
|
905
|
+
const times = this.times(entry);
|
|
906
|
+
if (times) {
|
|
907
|
+
const { atime, mtime } = times;
|
|
792
908
|
try {
|
|
793
909
|
fs.futimesSync(fd, atime, mtime);
|
|
794
910
|
}
|
|
795
|
-
catch (
|
|
911
|
+
catch (er) {
|
|
796
912
|
try {
|
|
797
|
-
fs.utimesSync(
|
|
913
|
+
fs.utimesSync(absolute, atime, mtime);
|
|
798
914
|
}
|
|
799
915
|
catch {
|
|
800
|
-
er
|
|
916
|
+
throw er;
|
|
801
917
|
}
|
|
802
918
|
}
|
|
803
919
|
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
const gid =
|
|
920
|
+
const owner = this.owner(entry);
|
|
921
|
+
if (owner) {
|
|
922
|
+
const { uid, gid } = owner;
|
|
807
923
|
try {
|
|
808
|
-
fs.fchownSync(fd,
|
|
924
|
+
fs.fchownSync(fd, uid, gid);
|
|
809
925
|
}
|
|
810
|
-
catch (
|
|
926
|
+
catch (er) {
|
|
811
927
|
try {
|
|
812
|
-
fs.chownSync(
|
|
928
|
+
fs.chownSync(absolute, uid, gid);
|
|
813
929
|
}
|
|
814
930
|
catch {
|
|
815
|
-
|
|
931
|
+
throw er;
|
|
816
932
|
}
|
|
817
933
|
}
|
|
818
934
|
}
|
|
819
|
-
oner(er);
|
|
820
|
-
});
|
|
821
|
-
}
|
|
822
|
-
[DIRECTORY](entry, done) {
|
|
823
|
-
const mode = typeof entry.mode === 'number' ? entry.mode & 0o7777 : this.dmode;
|
|
824
|
-
const er = this[MKDIR](String(entry.absolute), mode);
|
|
825
|
-
if (er) {
|
|
826
|
-
this[ONERROR](er, entry);
|
|
827
|
-
done();
|
|
828
|
-
return;
|
|
829
|
-
}
|
|
830
|
-
if (entry.mtime && !this.noMtime) {
|
|
831
|
-
try {
|
|
832
|
-
fs.utimesSync(String(entry.absolute), entry.atime || new Date(), entry.mtime);
|
|
833
|
-
/* c8 ignore next */
|
|
834
|
-
}
|
|
835
|
-
catch { }
|
|
836
935
|
}
|
|
837
|
-
|
|
936
|
+
catch (er) {
|
|
937
|
+
// Close the file one time, and do not use the descriptor again:
|
|
938
|
+
// the system can give its number to a different file.
|
|
838
939
|
try {
|
|
839
|
-
fs.
|
|
940
|
+
fs.closeSync(fd);
|
|
840
941
|
}
|
|
841
942
|
catch { }
|
|
943
|
+
throw er;
|
|
842
944
|
}
|
|
843
|
-
|
|
844
|
-
entry.resume();
|
|
845
|
-
}
|
|
846
|
-
[MKDIR](dir, mode) {
|
|
847
|
-
try {
|
|
848
|
-
return mkdirSync(normalizeWindowsPath(dir), {
|
|
849
|
-
uid: this.uid,
|
|
850
|
-
gid: this.gid,
|
|
851
|
-
processUid: this.processUid,
|
|
852
|
-
processGid: this.processGid,
|
|
853
|
-
umask: this.processUmask,
|
|
854
|
-
preserve: this.preservePaths,
|
|
855
|
-
unlink: this.unlink,
|
|
856
|
-
cwd: this.cwd,
|
|
857
|
-
mode: mode,
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
|
-
catch (er) {
|
|
861
|
-
return er;
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
[ENSURE_NO_SYMLINK](_entry, cwd, parts, done, onError) {
|
|
865
|
-
if (this.preservePaths || parts.length === 0)
|
|
866
|
-
return done();
|
|
867
|
-
let t = cwd;
|
|
868
|
-
for (const p of parts) {
|
|
869
|
-
t = path.resolve(t, p);
|
|
870
|
-
const [er, st] = callSync(() => fs.lstatSync(t));
|
|
871
|
-
if (er)
|
|
872
|
-
return done();
|
|
873
|
-
if (st.isSymbolicLink()) {
|
|
874
|
-
return onError(new SymlinkError(t, path.resolve(cwd, parts.join('/'))));
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
done();
|
|
878
|
-
}
|
|
879
|
-
[LINK](entry, linkpath, link, done) {
|
|
880
|
-
const linkSync = `${link}Sync`;
|
|
881
|
-
try {
|
|
882
|
-
fs[linkSync](linkpath, String(entry.absolute));
|
|
883
|
-
done();
|
|
884
|
-
entry.resume();
|
|
885
|
-
}
|
|
886
|
-
catch (er) {
|
|
887
|
-
return this[ONERROR](er, entry);
|
|
888
|
-
}
|
|
945
|
+
fs.closeSync(fd);
|
|
889
946
|
}
|
|
890
947
|
}
|
|
891
948
|
//# sourceMappingURL=unpack.js.map
|