The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
fix: a project closed before its first edit reopens empty, not corrupt
Jareer952f1315ca74
diff --git a/desktop/src-tauri/src/editor_api.rs b/desktop/src-tauri/src/editor_api.rsindex be3f6ce3..3c2a3309 100644--- a/desktop/src-tauri/src/editor_api.rs+++ b/desktop/src-tauri/src/editor_api.rs@@ -159,8 +159,16 @@ pub async fn editor_open(}}}- Editor::from_document(&document)- .ok_or_else(|| format!("{path} holds a document this build cannot read"))?+ match Editor::from_document(&document) {+ Some(editor) => editor,+ // The settings-only manifest `create` writes: a project+ // closed before its first edit reopens empty, it is not+ // corrupt (#12).+ None if projects::is_settings_only(&document) => Editor::new(),+ None => {+ return Err(format!("{path} holds a document this build cannot read"));+ }+ }}// No document yet - a project created moments ago.Err(_) => Editor::new(),diff --git a/desktop/src-tauri/src/projects.rs b/desktop/src-tauri/src/projects.rsindex 9f262276..dbcadd2d 100644--- a/desktop/src-tauri/src/projects.rs+++ b/desktop/src-tauri/src/projects.rs@@ -159,6 +159,17 @@ pub fn save(path: &str, document: &serde_json::Value) -> Result<(), String> {.map_err(|error| format!("could not replace {}: {error}", manifest.display()))}+/// True when a document carries no edit state at all - the settings-only+/// manifest `create` writes, in a project closed before its first save.+/// Such a document is a legitimately empty project. A document that claims+/// edit state the build then cannot load is a different thing: corrupt.+pub fn is_settings_only(document: &serde_json::Value) -> bool {+ document.is_object()+ && ["timelines", "tracks", "clips", "media"]+ .iter()+ .all(|key| document.get(key).is_none())+}+/// Reads the whole project document back.pub fn read_document(path: &str) -> Result<serde_json::Value, String> {let manifest = manifest_path(Path::new(path));@@ -297,6 +308,21 @@ mod tests {let _ = std::fs::remove_dir_all(&scratch);}+ #[test]+ fn a_fresh_manifest_is_settings_only_and_a_saved_edit_is_not() {+ // Exactly what `create` writes: settings, no edit state.+ let fresh = serde_json::json!({+ "wolfcut": "0.2.0",+ "name": "Untitled project",+ "video": { "width": 1080, "height": 1920, "rateNum": 30, "rateDen": 1 },+ });+ assert!(is_settings_only(&fresh));+ // Any edit state present means the document must load or fail loudly.+ assert!(!is_settings_only(&serde_json::json!({ "tracks": [] })));+ assert!(!is_settings_only(&serde_json::json!({ "timelines": "garbage" })));+ assert!(!is_settings_only(&serde_json::json!("nonsense")));+ }+#[test]fn paths_compare_case_insensitively() {assert!(same_path("D:\\Work\\Film", "d:\\work\\film"));