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

sync-all on Windows #3619

Merged
merged 2 commits into from
Apr 27, 2024
Merged

Conversation

Byron
Copy link
Collaborator

@Byron Byron commented Apr 27, 2024

After a file was moved into place on Windows, it's possible to call sync_all on Windows to force it to arrive for good,
at least so we hope.
If it works, the access-denied errors should go away (#3601), for now.

Thanks a lot, @daniilS, for suggesting to try this!

If it doesn't turn out to be effective, it appears we can always go back to the previous version of the code until more
flags could be tried, and possible submit a patch upstream eventually.

But even if it is effective, it introduces an extra syscall on Windows which shouldn't be required,
so ultimately the effectiveness of such an improvement in tempfile will have to be verified and then submitted upstream.

@Byron Byron force-pushed the no-tempfiles-on-windows branch 3 times, most recently from a9adb92 to ce724df Compare April 27, 2024 14:09
Byron added 2 commits April 27, 2024 16:11
GB writes files atomically and in the end it boils down to allocating bytes
and writing them all at once.

Now this capability lives in the `fs` module.
…rapp#3601)

Until `perist()` is truly atomic also on Windows, and modelled
[after Git](https://github.com/git/git/blob/master/compat/mingw.c#L2159-L2209),
sans the retries, it seems to work to just perform ordinary writes.

Before going there though, we try to call `sync_all()` on Windows to truly
finish the operation. On Unix, a rename is already supposed to be atomic.
@Byron Byron force-pushed the no-tempfiles-on-windows branch from ce724df to 4f58883 Compare April 27, 2024 14:20
@Byron Byron marked this pull request as ready for review April 27, 2024 14:35
@krlvi krlvi merged commit 15bce07 into gitbutlerapp:master Apr 27, 2024
23 checks passed
@Byron Byron deleted the no-tempfiles-on-windows branch April 28, 2024 13:41
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