@vltpkg/tar 1.3.3 → 1.3.4
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 +5 -5
- package/dist/link-tree.d.ts +10 -12
- package/dist/link-tree.js +31 -14
- package/dist/store-entry.d.ts +2 -2
- package/dist/store-entry.js +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -113,9 +113,9 @@ case-insensitive target (`EEXIST`) also return `false`.
|
|
|
113
113
|
(read + write into a fresh file); `ENOENT` while both the source and
|
|
114
114
|
the target's parent exist (overlayfs cross-layer links) does the same.
|
|
115
115
|
`EMLINK` copies that file only. Other link errors throw. Every file is
|
|
116
|
-
copied with `copy: true
|
|
117
|
-
|
|
118
|
-
marker (`<entry>.copied`), once.
|
|
116
|
+
copied with `copy: true`, or when package.json is copied after another
|
|
117
|
+
file was linked: a private package.json means nothing is shared. A
|
|
118
|
+
copy creates the entry's copied marker (`<entry>.copied`), once.
|
|
119
119
|
|
|
120
120
|
`VLT_STORE_VERIFY=1` checks the linked package.json size against the
|
|
121
121
|
index and removes the entry on a mismatch (debugging aid).
|
|
@@ -138,8 +138,8 @@ Sidecar path: `<storeEntry>.json`.
|
|
|
138
138
|
- `storeEntryLinked(storeEntry, index?)`: true if any file has another
|
|
139
139
|
hardlink, i.e. some `node_modules` uses it.
|
|
140
140
|
- `storeEntryCopied(storeEntry, index?)`: true if the entry has a
|
|
141
|
-
copied marker or install scripts (
|
|
142
|
-
show use.
|
|
141
|
+
copied marker or install scripts (copied before they run), i.e.
|
|
142
|
+
nlink cannot show use.
|
|
143
143
|
- `storeCopiedPath(storeEntry)`, `markStoreEntryCopied(storeEntry)`:
|
|
144
144
|
the copied marker, and its exclusive create.
|
|
145
145
|
- `storeEntryTime(storeEntry)`: sidecar mtime in ms (dir mtime without
|
package/dist/link-tree.d.ts
CHANGED
|
@@ -5,28 +5,26 @@ import type { StoreIndex } from './store-index.ts';
|
|
|
5
5
|
*/
|
|
6
6
|
export type StoreLinker = 'auto' | 'hardlink' | 'copy' | 'unpack';
|
|
7
7
|
/**
|
|
8
|
-
* How a store entry was placed (`copy`: every file copied, for
|
|
9
|
-
*
|
|
8
|
+
* How a store entry was placed (`copy`: every file copied, for `copy`
|
|
9
|
+
* or a downgrade) and its index, or false on a miss.
|
|
10
10
|
*/
|
|
11
11
|
export type StoreLinkResult = {
|
|
12
12
|
how: 'link' | 'copy';
|
|
13
13
|
index: StoreIndex;
|
|
14
14
|
} | false;
|
|
15
15
|
export type LinkFromStoreOptions = {
|
|
16
|
-
/**
|
|
17
|
-
* copy every file instead of hardlinking. Implied when the index says
|
|
18
|
-
* the package runs install scripts, which must not write into the store.
|
|
19
|
-
*/
|
|
16
|
+
/** copy every file instead of hardlinking */
|
|
20
17
|
copy?: boolean;
|
|
21
18
|
};
|
|
22
19
|
/**
|
|
23
20
|
* Materialize a global store entry at `target` from its sidecar index:
|
|
24
21
|
* hardlink each file into a sibling temp dir (package.json last), then
|
|
25
|
-
* rename it into place. Files that cannot be linked are copied
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
22
|
+
* rename it into place. Files that cannot be linked are copied; if
|
|
23
|
+
* package.json is copied after another file was linked, the whole
|
|
24
|
+
* package is copied, so a private package.json means nothing is shared.
|
|
25
|
+
* Returns how, with the index, or false, leaving `target` untouched, on
|
|
26
|
+
* a store miss (no valid index, entry not a directory, symlinked target
|
|
27
|
+
* parent), a name clash on a case-insensitive target, or a damaged
|
|
28
|
+
* entry, which is removed.
|
|
31
29
|
*/
|
|
32
30
|
export declare const linkFromStore: (storeEntry: string, target: string, { copy }?: LinkFromStoreOptions) => StoreLinkResult;
|
package/dist/link-tree.js
CHANGED
|
@@ -21,7 +21,7 @@ const place = (src, dst, exec, copy) => {
|
|
|
21
21
|
if (!copy && !copyAll) {
|
|
22
22
|
try {
|
|
23
23
|
linkSync(src, dst);
|
|
24
|
-
return
|
|
24
|
+
return 'link';
|
|
25
25
|
}
|
|
26
26
|
catch (er) {
|
|
27
27
|
const { code = '' } = er;
|
|
@@ -59,12 +59,13 @@ const place = (src, dst, exec, copy) => {
|
|
|
59
59
|
// store bins have every exec bit, whatever the umask
|
|
60
60
|
if (exec)
|
|
61
61
|
chmodSync(dst, statSync(src).mode & 0o777);
|
|
62
|
-
return
|
|
62
|
+
return 'copy';
|
|
63
63
|
};
|
|
64
64
|
/**
|
|
65
65
|
* Fill `tmp` from the entry. 'damaged': a source file is gone (or,
|
|
66
66
|
* with VLT_STORE_VERIFY=1, package.json changed size). 'clash': two
|
|
67
|
-
* index paths map to one name on a case-insensitive target.
|
|
67
|
+
* index paths map to one name on a case-insensitive target. 'mixed':
|
|
68
|
+
* package.json copied after another file was linked.
|
|
68
69
|
*/
|
|
69
70
|
const fill = (storeEntry, tmp, index, copy) => {
|
|
70
71
|
// Index paths are validated relative '/'-paths: concatenation is
|
|
@@ -77,17 +78,26 @@ const fill = (storeEntry, tmp, index, copy) => {
|
|
|
77
78
|
for (const d of index.dirs)
|
|
78
79
|
mkdirSync(tmp + sep + native(d));
|
|
79
80
|
let pj;
|
|
81
|
+
let linked = false;
|
|
80
82
|
for (const f of index.files) {
|
|
81
|
-
if (f[0] === 'package.json')
|
|
83
|
+
if (f[0] === 'package.json') {
|
|
82
84
|
pj = f;
|
|
83
|
-
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const how = put(f);
|
|
88
|
+
if (!how)
|
|
84
89
|
return 'damaged';
|
|
90
|
+
if (how === 'link')
|
|
91
|
+
linked = true;
|
|
85
92
|
}
|
|
86
93
|
if (!pj)
|
|
87
94
|
return;
|
|
88
95
|
// last, so an interrupted tmp dir never looks complete
|
|
89
|
-
|
|
96
|
+
const how = put(pj);
|
|
97
|
+
if (!how)
|
|
90
98
|
return 'damaged';
|
|
99
|
+
if (how === 'copy' && linked)
|
|
100
|
+
return 'mixed';
|
|
91
101
|
if (verify && statSync(tmp + sep + pj[0]).size !== pj[1]) {
|
|
92
102
|
return 'damaged';
|
|
93
103
|
}
|
|
@@ -101,12 +111,13 @@ const fill = (storeEntry, tmp, index, copy) => {
|
|
|
101
111
|
/**
|
|
102
112
|
* Materialize a global store entry at `target` from its sidecar index:
|
|
103
113
|
* hardlink each file into a sibling temp dir (package.json last), then
|
|
104
|
-
* rename it into place. Files that cannot be linked are copied
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
114
|
+
* rename it into place. Files that cannot be linked are copied; if
|
|
115
|
+
* package.json is copied after another file was linked, the whole
|
|
116
|
+
* package is copied, so a private package.json means nothing is shared.
|
|
117
|
+
* Returns how, with the index, or false, leaving `target` untouched, on
|
|
118
|
+
* a store miss (no valid index, entry not a directory, symlinked target
|
|
119
|
+
* parent), a name clash on a case-insensitive target, or a damaged
|
|
120
|
+
* entry, which is removed.
|
|
110
121
|
*/
|
|
111
122
|
export const linkFromStore = (storeEntry, target, { copy = false } = {}) => {
|
|
112
123
|
const index = readStoreIndex(storeEntry);
|
|
@@ -123,8 +134,14 @@ export const linkFromStore = (storeEntry, target, { copy = false } = {}) => {
|
|
|
123
134
|
let succeeded = false;
|
|
124
135
|
try {
|
|
125
136
|
mkdirSync(tmp);
|
|
126
|
-
|
|
127
|
-
|
|
137
|
+
let copied = copy;
|
|
138
|
+
let miss = fill(storeEntry, tmp, index, copied);
|
|
139
|
+
if (miss === 'mixed') {
|
|
140
|
+
rimrafSync(tmp);
|
|
141
|
+
mkdirSync(tmp);
|
|
142
|
+
copied = true;
|
|
143
|
+
miss = fill(storeEntry, tmp, index, copied);
|
|
144
|
+
}
|
|
128
145
|
if (miss === 'clash') {
|
|
129
146
|
debug('global store: name clash in target', storeEntry);
|
|
130
147
|
return false;
|
package/dist/store-entry.d.ts
CHANGED
|
@@ -25,8 +25,8 @@ export declare const removeStoreEntry: (storeEntry: string) => void;
|
|
|
25
25
|
export declare const storeEntryTime: (storeEntry: string) => number;
|
|
26
26
|
/**
|
|
27
27
|
* True if the global store entry has a valid sidecar and dir, and was
|
|
28
|
-
* copied from (marker) or has install scripts (
|
|
29
|
-
* the sidecar, if already read.
|
|
28
|
+
* copied from (marker) or has install scripts (copied before they
|
|
29
|
+
* run). `index`: the sidecar, if already read.
|
|
30
30
|
*/
|
|
31
31
|
export declare const storeEntryCopied: (storeEntry: string, index?: import("./store-index.ts").StoreIndex | undefined) => boolean;
|
|
32
32
|
/**
|
package/dist/store-entry.js
CHANGED
|
@@ -61,8 +61,8 @@ export const storeEntryTime = (storeEntry) => (statSync(storeIndexPath(storeEntr
|
|
|
61
61
|
statSync(storeEntry, noThrow))?.mtimeMs ?? 0;
|
|
62
62
|
/**
|
|
63
63
|
* True if the global store entry has a valid sidecar and dir, and was
|
|
64
|
-
* copied from (marker) or has install scripts (
|
|
65
|
-
* the sidecar, if already read.
|
|
64
|
+
* copied from (marker) or has install scripts (copied before they
|
|
65
|
+
* run). `index`: the sidecar, if already read.
|
|
66
66
|
*/
|
|
67
67
|
export const storeEntryCopied = (storeEntry, index = readStoreIndex(storeEntry)) => !!index &&
|
|
68
68
|
(index.scripts ||
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/tar",
|
|
3
3
|
"description": "An extremely limited and very fast tar extractor",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.4",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"url": "http://vlt.sh"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@vltpkg/error-cause": "1.3.
|
|
17
|
-
"@vltpkg/types": "1.3.
|
|
16
|
+
"@vltpkg/error-cause": "1.3.4",
|
|
17
|
+
"@vltpkg/types": "1.3.4",
|
|
18
18
|
"rimraf": "^6.1.2",
|
|
19
19
|
"tar": "^7.5.2"
|
|
20
20
|
},
|