Skip to content

Try to fix EPERM#185

Open
mifi wants to merge 3 commits intoisaacs:mainfrom
mifi:patch-1
Open

Try to fix EPERM#185
mifi wants to merge 3 commits intoisaacs:mainfrom
mifi:patch-1

Conversation

@mifi
Copy link
Copy Markdown

@mifi mifi commented Apr 17, 2020

See #104

setTimeout(function() {
fs.stat(to, function (stater, st) {
if (stater && stater.code === "ENOENT")
if ((stater && stater.code === "ENOENT") || (st && st.isFile()))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you explain this fix, maybe add a comment? Is the situation that to already exists but is maybe open by another process so windows gives EACCES or EPERM when trying to overwrite the destination?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, as explained in this #104 (comment) , after the stat check was added, he started seeing these errors. to already exists because it is a config file that is being atomically renamed to (overwritten). The stat check was added because the retry mechanism was causing a long retry delay in the case that to is a directory because it would give the same error and thereby retry until timeout. Therefore with st.isFile() it should still give up on directories.

@bpasero
Copy link
Copy Markdown

bpasero commented Jul 26, 2023

I think this change should go in 👍

@Stanzilla
Copy link
Copy Markdown

Would be nice to see this merged and released

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.

4 participants