Tests: the footage reload tests save a file in one step, so the watcher can't see it half written (#3689)

Co-authored-by: FredApps <FredApps@users.noreply.github.com>
This commit is contained in:
FredAppsandFredApps authored and GitHub committed 2026-11-14 17:10:36 +01:00
1 parent 4579f91c94
commit 5382b5ad01
1 file changed
+6 -2
+6 -2
View File
@@ -34,10 +34,14 @@ fn flat(rgba: [f32; 4], extra: bool) -> Vec<u8> {
write(&d)
}
/// Write `bytes` to `path` so its modification time moves even on coarse file systems.
/// Write `bytes` to `path` so its modification time moves even on coarse file systems. The file
/// is replaced in one step, as an application's save does: written in place, a watcher looking
/// every 20 ms can see it empty or half written and report the one save twice.
fn save(path: &str, bytes: &[u8]) {
std::thread::sleep(std::time::Duration::from_millis(30));
std::fs::write(path, bytes).unwrap();
let part = format!("{path}.part");
std::fs::write(&part, bytes).unwrap();
std::fs::rename(&part, path).unwrap();
}
fn footage(s: &Session, id: ItemId) -> Footage {