tgz: fix error handling
This commit is contained in:
@@ -39,19 +39,19 @@ function addToPack(pack, header, options) {
|
||||
const packEntry = safe(() => pack.entry(header, function (error) {
|
||||
if (error) {
|
||||
debug(`addToPack: error adding ${header.name} ${header.type} ${error.message}`);
|
||||
reject(error);
|
||||
reject(new BoxError(BoxError.FS_ERROR, error.message));
|
||||
} else {
|
||||
debug(`addToPack: added ${header.name} ${header.type}`);
|
||||
resolve();
|
||||
}
|
||||
}));
|
||||
|
||||
if (packEntry && options?.input) {
|
||||
safe(stream.pipeline(options.input, packEntry)); // background
|
||||
if (!packEntry) {
|
||||
return reject(new BoxError(BoxError.FS_ERROR, `Failed to add ${header.name}: ${safe.error.message}`));
|
||||
}
|
||||
|
||||
if (!packEntry) {
|
||||
reject(new Error(`Failed to add ${header.name}: ${safe.error.message}`));
|
||||
if (options?.input) {
|
||||
safe(stream.pipeline(options.input, packEntry), { debug }); // background. rely on pack.entry callback for promise completion
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -124,7 +124,7 @@ async function tarPack(dataLayout, encryption, uploader, progressCallback) {
|
||||
|
||||
pack.finalize();
|
||||
|
||||
const [error] = await safe(pipeline);
|
||||
const [error] = await pipeline; // already wrapped in safe()
|
||||
if (error) throw new BoxError(BoxError.EXTERNAL_ERROR, `tarPack pipeline error: ${error.message}`);
|
||||
debug(`tarPack: pipeline finished: ${JSON.stringify(ps.stats())}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user