mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-18 06:22:28 +03:00
try to fix regression on Windows due to tempfiles semantics (#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.
This commit is contained in:
parent
91d892882e
commit
4f58883bd4
@ -87,7 +87,12 @@ fn persist_tempfile(
|
|||||||
to_path: impl AsRef<Path>,
|
to_path: impl AsRef<Path>,
|
||||||
) -> std::io::Result<()> {
|
) -> std::io::Result<()> {
|
||||||
match tempfile.persist(to_path) {
|
match tempfile.persist(to_path) {
|
||||||
Ok(Some(_opened_file)) => Ok(()),
|
Ok(Some(_opened_file)) => {
|
||||||
|
// EXPERIMENT: Does this fix #3601?
|
||||||
|
#[cfg(windows)]
|
||||||
|
_opened_file.sync_all()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
Ok(None) => unreachable!(
|
Ok(None) => unreachable!(
|
||||||
"BUG: a signal has caused the tempfile to be removed, but we didn't install a handler"
|
"BUG: a signal has caused the tempfile to be removed, but we didn't install a handler"
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user