Skip to content
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

Auto-cleanup doesn't work #6

Closed
whmountains opened this issue Mar 2, 2016 · 5 comments
Closed

Auto-cleanup doesn't work #6

whmountains opened this issue Mar 2, 2016 · 5 comments

Comments

@whmountains
Copy link

Auto-cleanup directories isn't working for me. Here's what I'm doing:

tmp.dir({
    dir: '/tmp',
    unsafeCleanup: true
})
// and a long chain of .then

I am using the "unsafe cleanup" feature.

@benjamingr
Copy link
Owner

Thanks for fixing this and the PR!

(By the way, I recommend using the withDir function)

@whmountains
Copy link
Author

This issue still happens even with the fixes from #5. I haven't looked into why it's happening but I'm just resorting to manual cleanup for now.

@whmountains
Copy link
Author

Oh, I missed that the automatic cleanup only happens using the withDir function. Sorry about that.

@benjamingr
Copy link
Owner

@whmountains

Automatic cleanup should happen even without withDir if you do:

tmp.setGracefulCleanup();

Some people (like me) prefer not having magic code that's run on unhandledRejection so the disposer pattern is implemented for withDir with:

tmp.withDir(path => {
    // access the directory here, outside of this scope it is automatically cleaned
    return aPromise; // the dir gets deleted after a promise you return from here resolve.
});

@whmountains
Copy link
Author

Okay. That makes more sense. Thanks for filling me in.

Also thank you for adding me to the repo. That's the first time that's happened to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants