feat: atomic file saving - #1678
Conversation
|
I'd say this PR is ready for review, let me know what you think |
…or UNIX systems, use blocking instead of gio for async wrapper
|
I converted this PR to a draft as I was checking a couple of things:
Also, the crate atomic-write-file seems pretty good, which we could just use instead of relying on tempfile. |
|
This looks pretty good, could be ready to get merged. |
|
Seems like things don't always work on mac os. where the temp file is clearly visible here. In the app the "opened file was renamed or moved" popup shows before the "saved document successfully" (even if the final state is having modifications to save and needing to choose again a path for saving) |
Oh this is not going to be a very fun one to fix, multiple issues: 1 - Calling
|
|
Is this a mac-os specific thing ? (does it never happen/always work on everything else - aka linux with meson and flatpak, windows- no matter what ?) From other issues (like #990) maybe Maybe waiting on the Maybe (for rnote/crates/rnote-ui/src/canvas/mod.rs Lines 977 to 978 in 55ce8c9 is not true anymore (if it's really atomic we may have it once and setting the flag to false would work. Though not sure what happens for cloud storage) Currently we reset the flag here for rnote/crates/rnote-ui/src/canvas/mod.rs Lines 1039 to 1041 in 55ce8c9 (maybe this happen before the ModifyKind::Data event ?)
and here (but only if an error is found so probably not in my case) rnote/crates/rnote-ui/src/canvas/imexport.rs Lines 273 to 280 in 55ce8c9 |
|
Could you try again on macOS @Doublonmousse? Does the edit, this could be useful, the events read from |
|
Trying to add some traces (default debouncer config for now), going to redo with the latest commit shortly. pub(crate) fn set_output_file_expect_write(&self, expect_write: bool) {
debug!("set_output_file_expect_write to {:?}", expect_write);
self.imp().output_file_expect_write.set(expect_write);
}Shows that the value is never set back to false on mac os. is the event that triggers the issue (in Edit: same thing with the commit. Removing the debouncer timeout shows that this can also happen on the first save as well. |
|
Not the cleanest fix (if it even fixes the issue), but not the cleanest bug either... Does it work now? |
Yes it does |
|
Thanks! |
Split-off feature from #1578 with additional changes (the use of
tempfile)fixes #1128