FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
Engine: file.import refreshes the offline-missing list (#110)
Luna16116cc1c808c9c
diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rsindex 23f2dccd9..6ab6817b0 100644--- a/crates/engine/src/commands.rs+++ b/crates/engine/src/commands.rs@@ -858,6 +858,10 @@ fn build() -> Vec<CommandSpec> {if !image_sequences.is_empty() {out["imageSequences"] = json!(image_sequences);}+ // Newly imported files may resolve paths the project already listed as offline+ // (issue #110): rebuild s.offline.missing so the slate / "Media missing" badge clear+ // without the user having to reopen the project or relink item-by-item.+ crate::relink::refresh(s);Ok(out)}),cmd!(diff --git a/crates/engine/src/relink_tests.rs b/crates/engine/src/relink_tests.rsindex 81c85d013..1d8c1dfc0 100644--- a/crates/engine/src/relink_tests.rs+++ b/crates/engine/src/relink_tests.rs@@ -145,3 +145,31 @@ fn make_offline_shows_the_slate_until_relinked() {assert_eq!(frame_rgba(&mut s, 3, 1.0), online);let _ = std::fs::remove_dir_all(&root);}++// Regression test for issue #110: after `file.import` re-imports a file at a path the project+// already listed as offline, `s.offline.missing` must drop that item so the slate and the+// "Media missing" badge clear without reopening the project. Before the fix (the patch in+// `file.import` that calls `crate::relink::refresh(s)`), the slate stayed stale until reopen+// or per-item relink.+#[test]+fn reimport_clears_offline_list_after_path_resolves() {+ let root = tmp_dir("relink-reimport");+ let (path, items) = saved_project(&root);+ let a = root.join("Media/a.mov");++ // Delete a.mov so the saved project now points at a missing file, then reopen:+ // `on_open` → `refresh` → `scan` registers items[0] as missing.+ std::fs::remove_file(&a).unwrap();+ let mut s = open(&path);+ assert!(s.offline.missing.contains(&items[0]), "setup: a.mov missing on reopen");++ // Recreate the file at the exact path the project stores, then import. `file.import`+ // must drop items[0] from `s.offline.missing`. Without the fix, the entry stays stale+ // and the user has to reopen or `media.relink` each item.+ make_movie(&a, DemoScene::Aurora, W, H, 12);+ s.execute("file.import", json!({"paths": [a.to_string_lossy()]})).unwrap();+ assert!(!s.offline.missing.contains(&items[0]), "issue #110 — file.import did not refresh s.offline.missing (still contains {:?})", s.offline.missing);+ assert_eq!(s.execute("media.findMissing", json!({})).unwrap()["missing"].as_array().unwrap().len(), 0);++ let _ = std::fs::remove_dir_all(&root);+}