Skip to content

fix: graceful rename in windows#8036

Merged
patak-cat merged 1 commit intomainfrom
fix/graceful-rename
May 7, 2022
Merged

fix: graceful rename in windows#8036
patak-cat merged 1 commit intomainfrom
fix/graceful-rename

Conversation

@patak-cat
Copy link
Copy Markdown
Member

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?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

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)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown
Member

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.

@patak-cat patak-cat merged commit fe704f1 into main May 7, 2022
@patak-cat patak-cat deleted the fix/graceful-rename branch May 7, 2022 05:20
patak-cat added a commit that referenced this pull request May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants