Skip to content
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

refactor: use atomicwrites for writing replaced file #17

Merged
merged 2 commits into from
Oct 20, 2020

Conversation

acheronfail
Copy link
Owner

@acheronfail acheronfail commented Jul 9, 2020

@acheronfail acheronfail force-pushed the chore/housekeeping branch 5 times, most recently from fae1b86 to fae1bb5 Compare July 10, 2020 03:23
@acheronfail
Copy link
Owner Author

Investigate https://docs.rs/tempfile/3.1.0/tempfile/struct.TempPath.html#method.persist as a possible alternative

@acheronfail acheronfail added this to the 1.0.0 milestone Oct 17, 2020
@acheronfail acheronfail force-pushed the chore/housekeeping branch 3 times, most recently from fae18e1 to fae1959 Compare October 19, 2020 22:37
@acheronfail
Copy link
Owner Author

After some attempts I've narrowed down the issue to this: Stebalien/tempfile#131

After running some manual tests, the atomic replacement functions correctly on Windows, just not between two instances of NamedTempFile.

@acheronfail
Copy link
Owner Author

Okay, this has been fixed with some workarounds:

  • Need to use NamedTempFile::keep() (in tests) to let Windows then be able to write to that file
  • Need to drop the File object returned from the above before attempting to atomically replace (NamedTempFile::persist()) onto that file

@acheronfail acheronfail merged commit 879b2e3 into master Oct 20, 2020
@acheronfail acheronfail deleted the chore/housekeeping branch October 20, 2020 04:14
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.

1 participant