Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

fix: handle concurrent writes on windows #27

Merged
merged 1 commit into from
Sep 8, 2019

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Sep 7, 2019

Windows can return EPERM errors when trying to rename temp files to files that already exist. In our case a file with a given name will always have the same content so if it's created while we are trying to also create it, we can reasonably assume it's ok to use.

If we want to be more thorough we could hash the contents of the new file.

Windows returns EPERM errors when trying to rename temp files to
files that already exist. In our case a file with a given name
will always have the same content so if it's created while we
are trying to also create it, we can reasonably assume it's ok
to use.

If we want to be more thorough we could hash the contents of the
new file.
@achingbrain
Copy link
Member Author

Interestingly, this might be papering over a bug in node:

In the case that newPath already exists, it will be overwritten.
https://nodejs.org/api/fs.html#fs_fs_rename_oldpath_newpath_callback

Clearly not the case here.

@achingbrain
Copy link
Member Author

I have opened nodejs/node#29481 which demonstrates the issue without all the IPFS cruft around it.

@achingbrain achingbrain merged commit 4cee21c into v0.8.x Sep 8, 2019
@achingbrain achingbrain deleted the support-concurrent-writes-on-windows branch September 8, 2019 06:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant