1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-03 23:50:33 +02:00

Chore: Fixes #10285: Fix failing tarExtract test (#10295)

This commit is contained in:
Henry Heino
2024-04-11 00:43:39 -07:00
committed by GitHub
parent 1bb724fe0e
commit 1812587970

View File

@ -30,8 +30,12 @@ const tarExtract = async (options: TarExtractOptions) => {
throw new Error(`Extracting ${outPath} would overwrite`);
}
// Move to the next item when all available data has been read.
stream.once('end', () => next());
// Allows moving to the next item after all data for this entry has been read
// **and** this data has been processed.
// See https://github.com/laurent22/joplin/issues/10285
const streamEndPromise = new Promise<void>((resolve) => {
stream.once('end', () => resolve());
});
if (header.type === 'directory') {
await fsDriver.mkdir(outPath);
@ -46,7 +50,8 @@ const tarExtract = async (options: TarExtractOptions) => {
// Drain the rest of the stream.
stream.resume();
await streamEndPromise;
next();
});
let finished = false;