Skip to content

Commit

Permalink
fix: xz decompression issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kormide committed Nov 25, 2024
1 parent 0b382f4 commit d7616f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/domain/release-archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ export class ReleaseArchive {
cwd: extractDir
});
await decompressXz(reader, writer);
await new Promise(resolve => {
writer.on('finish', resolve);
writer.end();
});

return;
}

Expand Down
9 changes: 8 additions & 1 deletion src/infrastructure/xzdec/xzdec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,14 @@ export async function decompress(r: stream.Readable, w: stream.Writable) {
}
const outputLen = peekU32(mem, outputLenPtr);
if (outputLen > 0) {
w.write(Buffer.from(mem.buffer, outputPtr, outputLen));
await new Promise((resolve) => {
if (!w.write(Buffer.from(mem.buffer, outputPtr, outputLen))) {
w.once('drain', resolve)
}
else {
resolve(null);
}
});
}
}
}
Expand Down

0 comments on commit d7616f1

Please sign in to comment.