mirror of
https://github.com/storytold/filmcraft.git
synced 2026-11-28 14:18:48 -08:00
Move craft-fcproj-format to craft-libs 33fb95c7 and use its shared schema v19 (#5319)
craft-libs now defines the project schema as v18 (camera raw Source Settings) and v19 (Script items, storytold/craft-libs#3782). Move the craft-fcproj-format pin there (only that crate; the other craft-libs crates stay at a4db7995) and drop the app-local SCHEMA_VERSION bump, hand-built envelope and too-new workaround that #2726 added, since with the shared v19 they would write v20. Files written as v18 with Script items by builds from before this change read as v18 and upgrade through the shared no-op step; the test now covers both v17 and v18.
This commit is contained in:
1 parent
7b8e522d63
commit
8173ba3e01
4 files changed
+23
-27
No files matched your search
Generated
+1
-1
@@ -1419,7 +1419,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-fcproj-format"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=3af2280ee3434a2c860012df2f440652621c2c81#3af2280ee3434a2c860012df2f440652621c2c81"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=33fb95c7189686cab2fc0a6dbc1882ce7237e2c2#33fb95c7189686cab2fc0a6dbc1882ce7237e2c2"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ craft-exr = { version = "0.1.0", git = "https://github.com/storytold/craft-libs"
|
||||
craft-dpx = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a4db799563c9ccd7217e1731ec34c58f6ba57248" }
|
||||
# Shared YUV4MPEG2 parser and frame index.
|
||||
craft-jsonrpc = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a4db799563c9ccd7217e1731ec34c58f6ba57248", features = ["async-lines"] }
|
||||
craft-fcproj-format = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "3af2280ee3434a2c860012df2f440652621c2c81" }
|
||||
craft-fcproj-format = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "33fb95c7189686cab2fc0a6dbc1882ce7237e2c2" }
|
||||
craft-font-catalog = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a4db799563c9ccd7217e1731ec34c58f6ba57248", default-features = false }
|
||||
craft-control-protocol = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a4db799563c9ccd7217e1731ec34c58f6ba57248" }
|
||||
craft-y4m = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a4db799563c9ccd7217e1731ec34c58f6ba57248" }
|
||||
|
||||
+18
-23
@@ -41,7 +41,11 @@
|
||||
//! would drop them when saving.
|
||||
//! - **v16**: marker authors, named project swatches, and exact marker/clip hex colors.
|
||||
//! - **v17**: optional marker URLs, independent of notes and retained across marker-type changes.
|
||||
//! - **v18**: Script Project items with linked takes, marks, and independently positioned thumbnails.
|
||||
//! - **v18**: camera raw Source Settings on media items (`Interpretation::raw`, #1078), defined in
|
||||
//! storytold/craft-libs. This build does not have the settings yet. Builds from before the
|
||||
//! craft-libs pin move also wrote Script items as v18; those files read as v18 here and upgrade.
|
||||
//! - **v19**: Script Project items with linked takes, marks, and independently positioned thumbnails
|
||||
//! (#2726), defined in storytold/craft-libs.
|
||||
|
||||
#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]
|
||||
|
||||
@@ -54,10 +58,7 @@ use serde_json::Value;
|
||||
|
||||
pub use atomic::{atomic_write, atomic_write_new, atomic_write_no_follow};
|
||||
|
||||
pub use craft_fcproj_format::{FORMAT_ID, FormatError, MIGRATIONS, Migration, OLDEST_SCHEMA, detect_version, migrate_with};
|
||||
|
||||
/// Script items require a build that can preserve their takes and thumbnail positions.
|
||||
pub const SCHEMA_VERSION: u32 = craft_fcproj_format::SCHEMA_VERSION + 1;
|
||||
pub use craft_fcproj_format::{FORMAT_ID, FormatError, MIGRATIONS, Migration, OLDEST_SCHEMA, SCHEMA_VERSION, detect_version, migrate_with};
|
||||
|
||||
/// Largest project file this build will read (256 MiB). Project JSON is read whole, so
|
||||
/// larger files would commit several times their size in memory before validation.
|
||||
@@ -103,9 +104,7 @@ pub fn encode(project: &Project, pretty: bool) -> Vec<u8> {
|
||||
/// outside the schema's promises: builds that do not know it ignore it, and it is dropped rather
|
||||
/// than migrated when it cannot be read.
|
||||
pub fn encode_with_view(project: &Project, view: Option<&ProjectView>, pretty: bool) -> Vec<u8> {
|
||||
let envelope = craft_fcproj_format::EnvelopeOut { format: FORMAT_ID, schema_version: SCHEMA_VERSION, generator: generator(), project, view };
|
||||
let encoded = if pretty { serde_json::to_vec_pretty(&envelope) } else { serde_json::to_vec(&envelope) };
|
||||
encoded.unwrap_or_default()
|
||||
craft_fcproj_format::encode(project, view, generator(), pretty)
|
||||
}
|
||||
|
||||
/// Read a project file (any supported schema).
|
||||
@@ -113,15 +112,7 @@ pub fn decode(bytes: &[u8]) -> Result<Loaded, FormatError> {
|
||||
if bytes.len() as u64 > MAX_PROJECT_BYTES {
|
||||
return Err(FormatError::Corrupt(format!("project file is {} bytes, over the {MAX_PROJECT_BYTES} byte limit", bytes.len())));
|
||||
}
|
||||
let (env, found) = match craft_fcproj_format::decode::<Project>(bytes) {
|
||||
// The Script schema adds optional data. The shared migrations cover every earlier schema.
|
||||
Err(FormatError::TooNew { found, .. }) if found == SCHEMA_VERSION => {
|
||||
let env: craft_fcproj_format::EnvelopeIn<Project> = serde_json::from_slice(bytes).map_err(|e| FormatError::Corrupt(e.to_string()))?;
|
||||
(env, found)
|
||||
}
|
||||
Err(FormatError::TooNew { found, .. }) => return Err(FormatError::TooNew { found, supported: SCHEMA_VERSION }),
|
||||
result => result?,
|
||||
};
|
||||
let (env, found) = craft_fcproj_format::decode::<Project>(bytes)?;
|
||||
validate_loaded(loaded(env, found))
|
||||
}
|
||||
|
||||
@@ -229,7 +220,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn schema_version_matches_table() {
|
||||
assert_eq!(SCHEMA_VERSION, 18);
|
||||
assert_eq!(SCHEMA_VERSION, 19);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -320,11 +311,15 @@ mod tests {
|
||||
let second = doc.lines[1].id;
|
||||
let script = p.add_item("dialogue", Label::Blue, ItemKind::Script(Arc::new(doc)), None);
|
||||
assert!(decode(&encode(&p, false)).is_ok());
|
||||
// Previous Script builds saved these items in schema 17. Shared migrations must keep them.
|
||||
let older = craft_fcproj_format::encode(&p, None::<&filmcraft_project::ProjectView>, "FilmCraft test".into(), false);
|
||||
let loaded = decode(&older).unwrap();
|
||||
assert!(loaded.migrated());
|
||||
assert_eq!(loaded.project, p);
|
||||
// Earlier Script builds saved these items in schema 17, and builds before the shared Script
|
||||
// step in schema 18. Shared migrations must keep them.
|
||||
for version in [17, 18] {
|
||||
let mut older: Value = serde_json::from_slice(&encode(&p, false)).unwrap();
|
||||
older["schema_version"] = Value::from(version);
|
||||
let loaded = decode(&serde_json::to_vec(&older).unwrap()).unwrap();
|
||||
assert!(loaded.migrated());
|
||||
assert_eq!(loaded.project, p);
|
||||
}
|
||||
let doc = p.item_mut(script).unwrap().as_script_mut().unwrap();
|
||||
doc.lines[1].id = first;
|
||||
assert!(matches!(decode(&encode(&p, false)), Err(FormatError::Corrupt(_))));
|
||||
|
||||
@@ -8,7 +8,7 @@ writing them is `crates/format` (`filmcraft-format`); the engine's `file.*` comm
|
||||
```json
|
||||
{
|
||||
"format": "filmcraft.project",
|
||||
"schema_version": 18,
|
||||
"schema_version": 19,
|
||||
"generator": "FilmCraft 0.12.0",
|
||||
"project": { "name": "…", "settings": { … }, "root": { … }, "items": { … }, "next_id": 48 },
|
||||
"view": { "open_sequences": [21, 50], "active_sequence": 50, "sequences": { "21": { "pps": 40.0, "scroll": 0.0, … } } }
|
||||
@@ -57,7 +57,8 @@ writing them is `crates/format` (`filmcraft-format`); the engine's `file.*` comm
|
||||
| 15 | Project notes | Project notes default empty; no-op step |
|
||||
| 16 | Marker and custom colors | Marker authors, custom marker/clip colors and named project palettes; existing presets remain unchanged and new fields default empty; no-op step |
|
||||
| 17 | Marker URLs | Marker URLs default empty; older builds refuse v17 instead of silently discarding saved URLs; no-op step |
|
||||
| 18 | Script items | Preserves screenplay rows, linked takes, marks, and independent thumbnail positions. Existing projects need no data rewrite. |
|
||||
| 18 | Camera raw Source Settings | Defined in craft-libs for camera raw Source Settings on media items (#1078); this build does not have them yet. Builds from before the craft-libs pin move also wrote Script items as v18; those files upgrade normally; no-op step |
|
||||
| 19 | Script items | Preserves screenplay rows, linked takes, marks, and independent thumbnail positions. Existing projects need no data rewrite; no-op step |
|
||||
|
||||
### Migrations
|
||||
|
||||
|
||||
Reference in new issue
Block a user