Open WanGe2000 opened 1 year ago
Hmm... are you sure it isn't working as expected? I see two problems with the provided sample; first you're executing test()
synchronously and second, the filename has invalid hexadecimal escape sequence
(you need to be really careful with backslashes on string literals; \xxxx
seems to be the culprit of this)
When I modify the test slightly;
const StreamZip = require("node-stream-zip");
async function test() {
try {
// I'll do this inside the try-block to catch issues with opening the file too...
const zip = new StreamZip.async({
file: "443.zip" // for testing, bringing the file into current working directory
});
await zip.extract(null, "whatever");
} catch (error) {
console.error(error);
throw error; // So we can catch this outside of the function, too...
}
console.log("-----");
}
test()
.then(() => { console.done("File extracted?"); })
.catch((e) => { console.error("Problem?", e); })
.finally(() => { console.log("DONE!"); });
...it seems to work just as I would expect it to. Have I missed something?
Edit: Grantedly, the file I tested this with was an empty file, so results might differ when using an actual zip-file...
Thank you for your reply. You can try creating a new 5M disk and then extract a file larger than 5M using the extract api. You will receive an error like this
Error: ENOSPC: no space left on device, write Emitted 'error' event on WriteStream instance at: at WriteStream.onerror (_stream_readable.js:758:14) at WriteStream.emit (events.js:314:20) at emitErrorNT (internal/streams/destroy.js:106:8) at emitErrorCloseNT (internal/streams/destroy.js:74:3) at processTicksAndRejections (internal/process/task_queues.js:80:21) { errno: -4055, code: 'ENOSPC', syscall: 'write'}
but the error is not caught by try catch.
After testing, I found that the callback api also has this issues
const zip = new StreamZip({
file: "big.zip" // assume the big.zip is 50M
});
zip.on('ready', () => {
const outputPath = 'whatever' // assume the outputPath only left 10M space
zip.extract(null, outputPath , (err, count) => {
console.log(err ? 'Extract error' : `Extracted ${count} entries`);
zip.close();
});
});
same issue
same issue
` const StreamZip = require("node-stream-zip"); async function test() { const zip = new StreamZip.async({ file: "C:\Users\Administrator\AppData\Roaming\xxxx\mods\443.zip", }); try { await zip.extract(null, "G:\Monster Hunter"); } catch (error) { console.log(error); } console.log("-----"); } test()
`