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

tmp should use { recursive: true } when available with unsafeCleanup: true #276

Open
hasezoey opened this issue Jun 9, 2022 · 4 comments

Comments

@hasezoey
Copy link

hasezoey commented Jun 9, 2022

Operating System

any

NodeJS Version

12.10.0 - 14.14.0 | 14.14.0+

Tmp Version

0.2.1

Expected Behavior

when unsafeCleanup: true tmp should use nodejs native recursive delete when available, { recursive: true } for rmdir(Sync) is available since nodejs 12.10.0, until 14.14.0, where rm(Sync) should be used with { recursive: true }

reference: https://nodejs.org/api/fs.html#fsrmdirsyncpath-options

Experienced Behavior

uses rimraf for deleting files when unsafeCleanup: true is set, which sometimes (at least for me) results in removeCallback not actually being sync to deleting the directory

@silkentrance
Copy link
Collaborator

Thanks for the report @hasezoey.

In the past, I first tested the { recursive: true } option, however, I turned out that it would sometimes fail or did not behave in the way we needed it to, with the then available node version.
That is why we, reluctantly, incorporated rimraf.

I will see what this option does now and whether it behaves the way we need it to.

@silkentrance
Copy link
Collaborator

As for the removeCallback not being in sync is a question of the OS you are working under. Windows will lock open files and thus prevent rmdir from removing the directories these files are located in.
Sometimes, this goes as far as that node has to be shutdown prior to the lock being removed, leaving all directories in place, and one has to manually clean up the temporary storage.

@hasezoey
Copy link
Author

hasezoey commented Aug 25, 2022

Windows will lock open files and thus prevent rmdir from removing the directories these files are located in.

just for information, i am on Linux, so they should be unlinked if not directly removed (which recursively deleting (at least rm -rf) does)

@silkentrance
Copy link
Collaborator

Thanks for the information. I will see what I can do.

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

No branches or pull requests

2 participants