Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 89314fa

Browse files
committed
server: Report ZIP import errors properly
1 parent 347f180 commit 89314fa

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/services/import/zip.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,11 +629,17 @@ function readContent(zipfile: yauzl.ZipFile, entry: yauzl.Entry): Promise<Buffer
629629
function readZipFile(buffer: Buffer, processEntryCallback: (zipfile: yauzl.ZipFile, entry: yauzl.Entry) => void) {
630630
return new Promise((res, rej) => {
631631
yauzl.fromBuffer(buffer, {lazyEntries: true, validateEntrySizes: false}, function(err, zipfile) {
632-
if (err) throw err;
632+
if (err) rej(err);
633633
if (!zipfile) throw new Error("Unable to read zip file.");
634634

635635
zipfile.readEntry();
636-
zipfile.on("entry", entry => processEntryCallback(zipfile, entry));
636+
zipfile.on("entry", async entry => {
637+
try {
638+
await processEntryCallback(zipfile, entry);
639+
} catch (e) {
640+
rej(e);
641+
}
642+
});
637643
zipfile.on("end", res);
638644
});
639645
});

0 commit comments

Comments
 (0)