Commit b2a97e1
committed
Address unpack race conditions using path reservations
This addresses a race condition where one archive entry depends on an
earlier archive entry completing its unpack operation.
For example, a File entry followed by a Link to that file would fail if
the File was not written before the link() call was attempted, raising
an ENOENT.
Or, a File entry at a/b could be clobbered mid-write by an entry at
a/b/c.
This was never a problem for npm packages, because those tarballs are
created as a point-in-time snapshot of the package file tree. Indeed,
even in the generic case, it's a bit of an edge case. However, this
race condition led to some flaky tests, and could certainly be a problem
in general tar archive usage, especially if someone were to use
tar.update() often to append entries to an archive.
Address unpack race conditions using path reservations
This addresses a race condition where one archive entry depends on an
earlier archive entry completing its unpack operation.
For example, a File entry followed by a Link to that file would fail if
the File was not written before the link() call was attempted, raising
an ENOENT.
Or, a File entry at a/b could be clobbered mid-write by an entry at
a/b/c.
This was never a problem for npm packages, because those tarballs are
created as a point-in-time snapshot of the package file tree. Indeed,
even in the generic case, it's a bit of an edge case. However, this
race condition led to some flaky tests, and could certainly be a problem
in general tar archive usage, especially if someone were to use
tar.update() often to append entries to an archive.1 parent f0fe3aa commit b2a97e1
1 file changed
Lines changed: 27 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
3 | 9 | | |
4 | 10 | | |
5 | 11 | | |
| |||
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
| 19 | + | |
| 20 | + | |
13 | 21 | | |
14 | 22 | | |
15 | 23 | | |
| 24 | + | |
16 | 25 | | |
17 | 26 | | |
18 | 27 | | |
| |||
92 | 101 | | |
93 | 102 | | |
94 | 103 | | |
| 104 | + | |
| 105 | + | |
95 | 106 | | |
96 | 107 | | |
97 | 108 | | |
| |||
428 | 439 | | |
429 | 440 | | |
430 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
431 | 449 | | |
432 | | - | |
| 450 | + | |
| 451 | + | |
433 | 452 | | |
| 453 | + | |
434 | 454 | | |
435 | | - | |
| 455 | + | |
436 | 456 | | |
437 | | - | |
438 | | - | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
439 | 460 | | |
440 | 461 | | |
441 | 462 | | |
442 | 463 | | |
443 | 464 | | |
444 | | - | |
| 465 | + | |
| 466 | + | |
445 | 467 | | |
446 | 468 | | |
447 | 469 | | |
| |||
0 commit comments