removeCallback() fails after updating to 0.2.0
BryanHunt opened this issue · comments
Operating System
- Linux
- Windows 7
- Windows 10
- [x ] MacOS
- other:
NodeJS Version
- 0.x
- 4.x
- 6.x
- 7.x
- other: 12.16.2
Tmp Version
0.2.0
Expected Behavior
Clean up the tmp directory
Experienced Behavior
Error: ENOTEMPTY: directory not empty, rmdir '/var/folders/0p/35rj_jpx365f0plgs12ydxw40000gn/T/tmp-56630-mXjXpcliphmp'
If I revert to 0.1.0, the problem goes away.
@BryanHunt you need to configure the temporary directory with unsafeCleanup = true or call tmp.setUnsafeCleanup().
If you keep files in the temporary directory, then these will not be removed automatically, when removing the directory.
@BryanHunt I need your feedback here. Did adding the unsafeCleanup option solve your problem?
Alternatively provide us with example code that exploits this unwanted behaviour.
I need a day or so to try it out. I've been swamped with other work issues.
@BryanHunt okay. take your time.
I'm seeing similar behaviour on my end. Read-only files/folders cannot be automatically removed with version 0.2.0. This was working fine with 0.10. Could it be a regression introduced by the package now using RimRaf?
I was able to get unsafeCleanup = true working :)
@okcompute while this is not directly related to the issue, can you provide e.g. a gist with the steps you are taking that lead to the described behaviour? how come these files/directories become read only?
@okcompute you mean 0.1.0? this is already using rimraf.
@silkentrance Yes, I realized after the fact my comment should have been posted in a new issue :). We use node-tmp
in our test suite for creating temporary fixtures. In some cases, we are testing our system behaviour with read-only files. So we create a temporary directory. Create a random file in the temp folder. Set the read-only flag on that file. Run our test. And finally, call node-tmp
clean-up callback. With 0.1.0
, this works perfectly. With 0.2.0
, the clean up callback fails.
@okcompute you mean 0.1.0? this is already using rimraf.
Ok. My bad, I saw that RimRaf was added in my package-lock.json
. I thought this was coming from node-tmp
version update.
@okcompute have you tried creating the temporary directory with the option {unsafeCleanup: true}
?
Otherwise rimraf will not be used and tmp is expected to fail on non empty directories.
Yes, this is how I'm calling the function:
const tempDir = tmp.dirSync({ unsafeCleanup: true })
@okcompute after which you somehow create the files (using tmp.fileSync()?) and then set the readonly status, what is with the fd returned by tmp, do you detach it or discard it? if you detach it, you need to make sure that you close the file.
@okcompute please provide a gist of an example of the actual steps taken, including also the measures taken to create the temporary files. (pseudo code is ok.)
I create a file in the folder (not using tmp
). Manually set the read-only flag to the file. Run my test. Manually call tmp
cleanup function. I don't touch the fd
returned by tmp
.
@okcompute please provide a gist of an example of the actual steps taken
Will do.
@okcompute thanks, this will help a lot.
Considering this resolved. Having readonly files and directories inside the temporary directory created by tmp has not been on our radar yet and is an entirely different issue.
@okcompute feel free to open a new issue.