mirror of
https://github.com/storytold/lightcraft.git
synced 2026-11-28 01:09:49 +01:00
catalog: a failed rename of a streamed write removes its staging file only while it is still ours
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
a3cac015c1
commit
f8e5be997b
1 file changed
+4
-2
@@ -307,8 +307,10 @@ impl Store for FsStore {
|
||||
};
|
||||
check_staging(&self.folder, &tmp, &file)?;
|
||||
if let Err(e) = std::fs::rename(&tmp, self.path(name)) {
|
||||
// (the staging file is ours: it was just checked)
|
||||
let _ = std::fs::remove_file(&tmp);
|
||||
// (as in `write_atomic`: the staging file goes unless it came to belong to another save)
|
||||
if check_staging(&self.folder, &tmp, &file).is_ok() {
|
||||
let _ = std::fs::remove_file(&tmp);
|
||||
}
|
||||
return Err(e);
|
||||
}
|
||||
self.sync_dir();
|
||||
|
||||
Reference in new issue
Block a user