Skip to content

Commit 2be5f24

Browse files
authored
Pass --ignore-zeros to tar when decompressing zstd-compressed tarballs
See comment in the diff for full explanation.
1 parent 8c1551c commit 2be5f24

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/tar.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,16 @@ export async function extractTarZst(
168168

169169
try {
170170
// Initialize args
171-
const args = ["-x", "--zstd"];
171+
//
172+
// `--ignore-zeros` means that trailing zero bytes at the end of an archive will be read
173+
// by `tar` in case a further concatenated archive follows. Otherwise when a tarball built
174+
// by GNU tar, which writes many trailing zeroes, is read by BSD tar, which expects less, then
175+
// BSD tar can hang up the pipe to its filter program early, and if that program is `zstd`
176+
// then it will try to write the remaining zeroes, get an EPIPE error because `tar` has closed
177+
// its end of the pipe, return 1, and `tar` will pass the error along.
178+
//
179+
// See also https://github.com/facebook/zstd/issues/4294
180+
const args = ["-x", "--zstd", "--ignore-zeros"];
172181

173182
if (tarVersion.type === "gnu") {
174183
// Suppress warnings when using GNU tar to extract archives created by BSD tar

0 commit comments

Comments
 (0)