-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix non closed zip file on windows: use yaulz autoClose=true option #5
Conversation
Thank you @khelkun :), would be great to have tests for this :) |
Not easily testable:
test('onezip: extract and remove zip (ensure zip file has been released by yaulz)', async (t) => {
const to = tmp();
const fixture = join(__dirname, 'fixture');
const source = join(fixture, 'onezip.txt.zip');
const from = join(fixture, 'onezip.txt.cpy.zip');
copyFileSync(source, from);
const extracter = extract(from, to);
await once(extracter, 'end');
const pathUnpacked = join(to, 'onezip.txt');
readFileSync(pathUnpacked);
unlinkSync(pathUnpacked);
rmdirSync(to);
unlinkSync(from);
let fromExists = true;
try
{
statSync(from);
}
catch(error)
{
fromExists = false;
}
t.false(fromExists, 'source zip file has been deleted (zip file released afetr extraction)');
t.end();
}) I ran that test in debug with a breakpoint on
With This is really Windows filesystem weird stuff. You may not be able to reproduced #4 because the zip file is actually removed as soon as your node program ends. For me that's not an option because the unzip and zip file remove occurs in a service that never ends. |
Thank you 🙂, landed in v4.2.1 🎉 |
#4
https://www.npmjs.com/package/yauzl#openpath-options-callback