Skip to content

Commit bf84079

Browse files
author
Michael Smith
committed
(cherry picked from commit 91bd674)
1 parent bdef82c commit bf84079

7 files changed

Lines changed: 97 additions & 29 deletions

File tree

‎node_modules/tar/dist/commonjs/index.min.js‎

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

‎node_modules/tar/dist/commonjs/pack.js‎

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class PackJob {
5454
stat;
5555
readdir;
5656
pending = false;
57+
pendingLink = false;
5758
ignore = false;
5859
piped = false;
5960
constructor(path, absolute) {
@@ -71,6 +72,7 @@ const EOF = Buffer.alloc(1024);
7172
const ONSTAT = Symbol('onStat');
7273
const ENDED = Symbol('ended');
7374
const QUEUE = Symbol('queue');
75+
const PENDINGLINKS = Symbol('queue');
7476
const CURRENT = Symbol('current');
7577
const PROCESS = Symbol('process');
7678
const PROCESSING = Symbol('processing');
@@ -122,6 +124,7 @@ class Pack extends minipass_1.Minipass {
122124
// class, but then we'd have to be tracking the tail of the queue the
123125
// whole time, and Yallist just does that for us anyway.
124126
[QUEUE];
127+
[PENDINGLINKS] = new Map();
125128
[JOBS] = 0;
126129
[PROCESSING] = false;
127130
[ENDED] = false;
@@ -279,14 +282,26 @@ class Pack extends minipass_1.Minipass {
279282
}
280283
else if (stat.isFile() &&
281284
stat.nlink > 1 &&
282-
job === this[CURRENT] &&
283285
!this.linkCache.get(`${stat.dev}:${stat.ino}`) &&
284286
!this.sync) {
285-
// if it's not filtered, and it's a new File entry,
286-
// jump the queue in case any pending Link entries are about
287-
// to try to link to it. This prevents a hardlink from coming ahead
288-
// of its target in the archive.
289-
this[PROCESSJOB](job);
287+
// if it's not filtered, and it's a new File entry, and next anyway
288+
// process right away in case any pending Link entries are about
289+
// to try to link to it.
290+
if (job === this[CURRENT]) {
291+
this[PROCESSJOB](job);
292+
}
293+
else {
294+
// if it's NOT the current entry, it needs to be deferred,
295+
// so that the link target can be built first.
296+
const key = `${stat.dev}:${stat.ino}`;
297+
const pending = this[PENDINGLINKS].get(key);
298+
if (pending)
299+
pending.push(job);
300+
else
301+
this[PENDINGLINKS].set(key, [job]);
302+
job.pendingLink = true;
303+
job.pending = true;
304+
}
290305
}
291306
this[PROCESS]();
292307
}
@@ -334,12 +349,31 @@ class Pack extends minipass_1.Minipass {
334349
get [CURRENT]() {
335350
return this[QUEUE] && this[QUEUE].head && this[QUEUE].head.value;
336351
}
337-
[JOBDONE](_job) {
352+
[JOBDONE](job) {
338353
this[QUEUE].shift();
339354
this[JOBS] -= 1;
355+
const { stat } = job;
356+
if (stat && stat.isFile() && stat.nlink > 1) {
357+
// might be a file with pending links
358+
const key = `${stat.dev}:${stat.ino}`;
359+
const pending = this[PENDINGLINKS].get(key);
360+
if (pending) {
361+
this[PENDINGLINKS].delete(key);
362+
for (const job of pending) {
363+
job.pending = false;
364+
this[PROCESSJOB](job);
365+
}
366+
}
367+
}
340368
this[PROCESS]();
341369
}
342370
[PROCESSJOB](job) {
371+
if (job.pending && job.pendingLink && job === this[CURRENT]) {
372+
// At least one of the links to this file are not being included
373+
// in the tarball, so we need to just proceed.
374+
job.pending = false;
375+
job.pendingLink = false;
376+
}
343377
if (job.pending) {
344378
return;
345379
}

‎node_modules/tar/dist/esm/index.min.js‎

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

‎node_modules/tar/dist/esm/pack.js‎

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export class PackJob {
1515
stat;
1616
readdir;
1717
pending = false;
18+
pendingLink = false;
1819
ignore = false;
1920
piped = false;
2021
constructor(path, absolute) {
@@ -31,6 +32,7 @@ const EOF = Buffer.alloc(1024);
3132
const ONSTAT = Symbol('onStat');
3233
const ENDED = Symbol('ended');
3334
const QUEUE = Symbol('queue');
35+
const PENDINGLINKS = Symbol('queue');
3436
const CURRENT = Symbol('current');
3537
const PROCESS = Symbol('process');
3638
const PROCESSING = Symbol('processing');
@@ -82,6 +84,7 @@ export class Pack extends Minipass {
8284
// class, but then we'd have to be tracking the tail of the queue the
8385
// whole time, and Yallist just does that for us anyway.
8486
[QUEUE];
87+
[PENDINGLINKS] = new Map();
8588
[JOBS] = 0;
8689
[PROCESSING] = false;
8790
[ENDED] = false;
@@ -239,14 +242,26 @@ export class Pack extends Minipass {
239242
}
240243
else if (stat.isFile() &&
241244
stat.nlink > 1 &&
242-
job === this[CURRENT] &&
243245
!this.linkCache.get(`${stat.dev}:${stat.ino}`) &&
244246
!this.sync) {
245-
// if it's not filtered, and it's a new File entry,
246-
// jump the queue in case any pending Link entries are about
247-
// to try to link to it. This prevents a hardlink from coming ahead
248-
// of its target in the archive.
249-
this[PROCESSJOB](job);
247+
// if it's not filtered, and it's a new File entry, and next anyway
248+
// process right away in case any pending Link entries are about
249+
// to try to link to it.
250+
if (job === this[CURRENT]) {
251+
this[PROCESSJOB](job);
252+
}
253+
else {
254+
// if it's NOT the current entry, it needs to be deferred,
255+
// so that the link target can be built first.
256+
const key = `${stat.dev}:${stat.ino}`;
257+
const pending = this[PENDINGLINKS].get(key);
258+
if (pending)
259+
pending.push(job);
260+
else
261+
this[PENDINGLINKS].set(key, [job]);
262+
job.pendingLink = true;
263+
job.pending = true;
264+
}
250265
}
251266
this[PROCESS]();
252267
}
@@ -294,12 +309,31 @@ export class Pack extends Minipass {
294309
get [CURRENT]() {
295310
return this[QUEUE] && this[QUEUE].head && this[QUEUE].head.value;
296311
}
297-
[JOBDONE](_job) {
312+
[JOBDONE](job) {
298313
this[QUEUE].shift();
299314
this[JOBS] -= 1;
315+
const { stat } = job;
316+
if (stat && stat.isFile() && stat.nlink > 1) {
317+
// might be a file with pending links
318+
const key = `${stat.dev}:${stat.ino}`;
319+
const pending = this[PENDINGLINKS].get(key);
320+
if (pending) {
321+
this[PENDINGLINKS].delete(key);
322+
for (const job of pending) {
323+
job.pending = false;
324+
this[PROCESSJOB](job);
325+
}
326+
}
327+
}
300328
this[PROCESS]();
301329
}
302330
[PROCESSJOB](job) {
331+
if (job.pending && job.pendingLink && job === this[CURRENT]) {
332+
// At least one of the links to this file are not being included
333+
// in the tarball, so we need to just proceed.
334+
job.pending = false;
335+
job.pendingLink = false;
336+
}
303337
if (job.pending) {
304338
return;
305339
}

‎node_modules/tar/package.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Isaac Z. Schlueter",
33
"name": "tar",
44
"description": "tar for node",
5-
"version": "7.5.13",
5+
"version": "7.5.15",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/isaacs/node-tar.git"
@@ -38,13 +38,13 @@
3838
"events-to-array": "^2.0.3",
3939
"mutate-fs": "^2.1.1",
4040
"nock": "^13.5.4",
41-
"oxlint": "^1.56.0",
42-
"oxlint-tsgolint": "^0.17.0",
41+
"oxlint": "^1.57.0",
42+
"oxlint-tsgolint": "^0.17.3",
4343
"prettier": "^3.8.1",
4444
"rimraf": "^6.1.2",
4545
"tap": "^21.6.2",
4646
"tshy": "^3.3.2",
47-
"typedoc": "^0.28.17"
47+
"typedoc": "^0.28.18"
4848
},
4949
"license": "BlueOak-1.0.0",
5050
"engines": {

‎package-lock.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
"spdx-expression-parse": "^4.0.0",
143143
"ssri": "^13.0.1",
144144
"supports-color": "^10.2.2",
145-
"tar": "^7.5.13",
145+
"tar": "^7.5.15",
146146
"text-table": "~0.2.0",
147147
"tiny-relative-date": "^2.0.2",
148148
"treeverse": "^3.0.0",
@@ -13484,9 +13484,9 @@
1348413484
}
1348513485
},
1348613486
"node_modules/tar": {
13487-
"version": "7.5.13",
13488-
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.13.tgz",
13489-
"integrity": "sha512-tOG/7GyXpFevhXVh8jOPJrmtRpOTsYqUIkVdVooZYJS/z8WhfQUX8RJILmeuJNinGAMSu1veBr4asSHFt5/hng==",
13487+
"version": "7.5.15",
13488+
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.15.tgz",
13489+
"integrity": "sha512-dzGK0boVlC4W5QFuQN1EFSl3bIDYsk7Tj40U6eIBnK2k/8ml7TZ5agbI5j5+qnoVcAA+rNtBml8SEiLxZpNqRQ==",
1349013490
"inBundle": true,
1349113491
"license": "BlueOak-1.0.0",
1349213492
"dependencies": {

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
"spdx-expression-parse": "^4.0.0",
111111
"ssri": "^13.0.1",
112112
"supports-color": "^10.2.2",
113-
"tar": "^7.5.13",
113+
"tar": "^7.5.15",
114114
"text-table": "~0.2.0",
115115
"tiny-relative-date": "^2.0.2",
116116
"treeverse": "^3.0.0",

0 commit comments

Comments
 (0)