M3.14: project files name the version that wrote them, never save unreadable, keep their format
- `Project::to_file_json` writes `savedBy` (the EffectCraft version) ahead of the project and checks that the text reads back before anything is written: JSON has no NaN or infinity, so such a value made a file that saved but could never be opened. Save now fails with a message and the file on disk is left as it was. - Opening a project saved by a newer EffectCraft warns that settings this version doesn't know are lost on saving; `file.open` reports `savedBy`. A file that isn't a project names itself in the error. - Increment and Save keeps the extension (`.ecprojx` stays XML); Save a Copy writes XML for `.ecprojx` / `.xml` paths, like Save As. - Docs: architecture (document model), parity. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6fc39eb133
commit
948f06fbf2
@@ -104,3 +104,19 @@ fn same_content_ignores_unused_ids_and_sees_comp_edits() {
|
||||
r.settings.bit_depth = crate::BitDepth::Bpc16;
|
||||
assert!(!r.same_content(&p));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_files_name_their_version_and_always_read_back() {
|
||||
let (mut p, cid) = project_with_layer();
|
||||
let text = p.to_file_json().unwrap();
|
||||
assert_eq!(crate::saved_by(&text).as_deref(), Some(crate::APP_VERSION));
|
||||
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");
|
||||
// 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();
|
||||
assert!(e.contains("can't be saved"), "{e}");
|
||||
assert!(crate::is_newer_version("0.2.0", "0.1.9") && crate::is_newer_version("1.0.0-rc.1", "0.9.9"));
|
||||
assert!(!crate::is_newer_version("0.1.1", "0.1.1") && !crate::is_newer_version("0.1.0", "0.1.1"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user