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

Create unique temp directories and clean up afterwards #370

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

SpoonMeiser
Copy link

Use os.tmpdir and fs.mkdtemp to create a uniquely named temporary directory in the correct place.

Also attempt to remove the temporary directory on application exit. This uses fs.rmSync which is only available in Node 14, which might be too new.

@joethephish
Copy link
Member

Thanks for this! I have a couple of questions, if you don't mind?

  • We've had some issues with with temporary directories in the past since it's platform dependent. Can I ask what platform(s) you've tested on?
  • When you say that fs.rmSync is only available in Node 14 which may be too new. Did it work for you when you tested? Any reason to believe it won't work otherwise? Our version of Electron is super outdated so I wouldn't be surprised if we had issues with APIs being too new!

@SpoonMeiser
Copy link
Author

Unfortunately I'm only able to test on Linux

Instead of using rmSync, I could add another npm dependency for a package that does the same in older versions of node (at least one page recommended del) if that is acceptable?

The behaviour if the function doesn't exist is an error message in the console, and the directory not being deleted, which isn't very different from the current behaviour, although potentially more annoying to manually cleanup now if there are multiple temp directories lying about.

For compatability with older versions of node
@SpoonMeiser
Copy link
Author

I've added a new commit that adds del as an additional dependency, and uses this to delete the temp directory. This should work with older versions of node.

@SpoonMeiser
Copy link
Author

Also, although this replaces the changes from #223, I did test that this does still respect TMPDIR on Linux (and I assume also OSX)

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

Successfully merging this pull request may close these issues.

None yet

2 participants