EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Project files: read savedBy through craft-ecproj-format's Head
dotCooCoob133c0500f45
diff --git a/Cargo.lock b/Cargo.lockindex 097361d61..76fb9cf31 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1097,7 +1097,7 @@ source = "git+https://github.com/storytold/craft-libs?rev=92d392cff132eaf53e13af[[package]]name = "craft-ecproj-format"version = "0.1.0"-source = "git+https://github.com/storytold/craft-libs?rev=246e8f837347ac642d6852df89e1425630111d21#246e8f837347ac642d6852df89e1425630111d21"+source = "git+https://github.com/storytold/craft-libs?rev=d74959fb9caca1c5fd393b4351026885b5ba0cc8#d74959fb9caca1c5fd393b4351026885b5ba0cc8"dependencies = ["serde","serde_json",diff --git a/Cargo.toml b/Cargo.tomlindex 6f8552723..c3f25e652 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -14,7 +14,7 @@ repository = "https://github.com/storytold/effectcraft"craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0", version = "=0.1.0", default-features = false, features = ["read"] }craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0" }craft-quit = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0" }-craft-ecproj-format = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "246e8f837347ac642d6852df89e1425630111d21" }+craft-ecproj-format = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "d74959fb9caca1c5fd393b4351026885b5ba0cc8" }# craft-update: app-specific pretend versions apply to startup and manual checks.craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7", features = ["egui"] }# internaldiff --git a/crates/project/src/settings.rs b/crates/project/src/settings.rsindex aace78cdc..29353908f 100644--- a/crates/project/src/settings.rs+++ b/crates/project/src/settings.rs@@ -12,8 +12,15 @@ pub const SCHEMA_EFFECT_SPACE: u32 = 2;/// The EffectCraft version, written into project files as `savedBy`.pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION");-/// The EffectCraft version that wrote a project file (its `savedBy`), when it says.-pub use craft_ecproj_format::saved_by;+/// The EffectCraft version that wrote a project file (its `savedBy`), when it says, also for a+/// project whose schema is newer than [`SCHEMA_VERSION`].+pub fn saved_by(text: &str) -> Option<String> {+ match craft_ecproj_format::Head::read(text) {+ Ok(head) => head.saved_by,+ Err(craft_ecproj_format::ReadError::TooNew { saved_by, .. }) => saved_by,+ Err(_) => None,+ }+}/// The compositions that were open when a project file was saved and their current times/// (`activeComp`, `openComps` and `compTimes` next to `savedBy`), so it reopens where it was leftdiff --git a/crates/project/src/tests.rs b/crates/project/src/tests.rsindex a3e41adb5..a47792b89 100644--- a/crates/project/src/tests.rs+++ b/crates/project/src/tests.rs@@ -162,6 +162,8 @@ fn project_files_name_their_version_and_always_read_back() {assert!(text.trim_start().starts_with("{\n \"savedBy\""), "the version comes first");assert_eq!(Project::from_json(&text).unwrap(), p);assert_eq!(crate::saved_by(&p.to_json()), None, "plain JSON (worker hand-offs) has none");+ assert_eq!(crate::saved_by(r#"{"savedBy": "999.0.0", "schema": 3}"#).as_deref(), Some("999.0.0"), "a newer schema still names its version");+ assert_eq!(crate::saved_by(r#"[2, {}, {}, 1]"#), None, "the array form has none");// JSON can't hold NaN: saving refuses instead of writing a file that can't be opened.p.comp_mut(cid).unwrap().layers[0].props.prop_mut("transform/opacity").unwrap().value = Value::Scalar(f64::NAN);let e = p.to_file_json().unwrap_err().to_string();