-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
fix: graceful rename in windows #8036
Conversation
@@ -775,8 +775,8 @@ function gracefulRename( | |||
) { | |||
setTimeout(function () { | |||
fs.stat(to, function (stater, st) { | |||
if (stater && stater.code === 'ENOENT') gracefulRename(from, to, CB) | |||
else cb(er) | |||
if (stater && stater.code === 'ENOENT') fs.rename(from, to, CB) |
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.
This was a mistake when doing the translation to our code, see:
https://github.com/isaacs/node-graceful-fs/blob/1f19b0b467e4144260b397343cd60f37c5bdcfda/polyfills.js#L109
if (stater && stater.code === 'ENOENT') gracefulRename(from, to, CB) | ||
else cb(er) | ||
if (stater && stater.code === 'ENOENT') fs.rename(from, to, CB) | ||
else CB(er) |
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.
This seems to be a bug on node-graceful-fs. If the code isn't 'ENOENT'
, it means the directory still exists and we should keep retrying. So we need to call CB
. Calling cb
ends the recursion returning the original error.
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.
Great catch. This makes sense to me too after catching the flow.
Description
Fix a bug in graceful-fs rename polyfill that we based on
https://github.com/isaacs/node-graceful-fs/blob/1f19b0b467e4144260b397343cd60f37c5bdcfda/polyfills.js#L111
See context at #7939 (comment)
What is the purpose of this pull request?