-
Notifications
You must be signed in to change notification settings - Fork 93
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
Added removeCallback passing #25
Conversation
@@ -167,9 +167,21 @@ function _createTmpFile(options, callback) { | |||
fs.open(name, _c.O_CREAT | _c.O_EXCL | _c.O_RDWR, opts.mode || 0600, function _fileCreated(err, fd) { | |||
if (err) return cb(err); | |||
|
|||
if (!opts.keep) _removeObjects.unshift([ fs.unlinkSync, name ]); | |||
var removed = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason the keep the remove variable? Only the removeCallback
function could set this var and therefore will be never true at the check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you're protecting the code from the double call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a protection from double call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is not enough protection, I think it would be better to do an fs.exists
check before the removal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just protects from double call.
But not from double delete if user deletes file by themselves.
Also the last variant was not covered earlier. I think it should be a separate change.
Please also add tests for this functionality. |
tests
Added tests. Made some refactoring. |
Great, thank you very much! |
Cool! |
Sure, I'll do that soon. |
Added removeCallback passing.
Usefull for daemons that need to create some directory and remove it when the work is done.