Closed okcompute closed 4 years ago
This issue was first reported in an unrelated issue: https://github.com/raszi/node-tmp/issues/251
Btw, the behaviour change I'm exposing may be a good thing. I was discussing with a colleague about this issue and he exposed that rimraf
basically replicate rm -rf
. And doing rm -rf
on a read-only folder in the terminal will fail!
@okcompute if you set up a small test project and then run index.js, you will find that the tmp folder has not been cleaned up and still resides under e.g. /tmp.
This was actually a bug in 0.1.0 which used asynchronous code when it was expected to do synchronous cleanup. In addition, any exceptions will be caught.
I just ran the example and here is what is left in /tmp:
> find /tmp/tmp-26244oEcZlrGrKBrS/
/tmp/tmp-26244oEcZlrGrKBrS/
/tmp/tmp-26244oEcZlrGrKBrS/folder
/tmp/tmp-26244oEcZlrGrKBrS/folder/my-file.txt
And rimraf does not handle readonly files or dirs at all.
So I would call this a rather specific use case and I am not so sure whether we would want to handle this as it requires changes to an external library, which we introduced in order to not having to deal with all the platform specific stuff by ourselves.
@okcompute maybe you can rethink your use case and why you would need the folder or files to be readonly in the first place. Maybe this might solve your problem then?
@silkentrance Thank you for the explanation! I will update to version 0.2.1
and change my test to remove the fixture read-only flag before cleanup. I'm glad we now understand where this behaviour change is coming from 🙂️. Thanks again!
Operating System
NodeJS Version
Tmp Version
0.2.0 and +
Expected Behavior
I expect
tmp.removeCallback
to delete read-only folder when I set theunsafeCleanup
flag totrue
when using a temporary directory created withtmp.dirSync
. This was working usingtmp
version0.1.0
.Experienced Behavior
With
0.2.0
and up,tmp.removeCallback
throws anEACCESS
error when read-only folder are present in a temporary directory:Here is the code I used to reproduce the problem: