EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
automation: an output module template is an output nobody named (#2479)
Anubhav Rai9cc232096c18
diff --git a/crates/automation/src/confine.rs b/crates/automation/src/confine.rsindex b646ba7ba..d9807ca40 100644--- a/crates/automation/src/confine.rs+++ b/crates/automation/src/confine.rs@@ -169,6 +169,9 @@ impl Confinement {(None, None) => (&[][..], Access::Read),};let mut given = false;+ // Whether one of them is a file and not a Render Queue template, whose own output is+ // relative and resolved like one the agent never gave.+ let mut gave_a_file = false;for key in named {let Some(v) = params.get(*key).filter(|v| !v.is_null()) else { continue };given = true;@@ -181,6 +184,7 @@ impl Confinement {match p.as_str() {Some(s) if id == "render.preRender" && !looks_like_path(s) => {}Some(s) => {+ gave_a_file = true;self.check(s, access)?;}None => return Err(Error::BadArgs(format!("`{id}`: `{key}` must be a path"))),@@ -203,7 +207,7 @@ impl Confinement {// home folder when the project has never been saved, outside every root (#2479). Only// that last case is certainly outside, and reading the preference here would duplicate// the engine's precedence, so an unsaved project is told to name its output instead.- if QUEUES_AN_OUTPUT.contains(&id) && !given {+ if QUEUES_AN_OUTPUT.contains(&id) && !gave_a_file {lookups.push(Lookup::DefaultOutput);}if IMPLICIT_WRITES.contains(&id) && !(given && id == "file.save") {diff --git a/crates/automation/src/tests.rs b/crates/automation/src/tests.rsindex 55cc3b3cd..3c5620fbf 100644--- a/crates/automation/src/tests.rs+++ b/crates/automation/src/tests.rs@@ -1402,6 +1402,10 @@ fn automation_roots_refuse_a_queued_output_from_an_unsaved_project() {let msg = c[0]["text"].as_str().unwrap_or_default();assert!(msg.contains("the project has no file yet"), "`{command}`: {msg}");}+ // Naming an Output Module template instead of a file is the same: its own output is relative.+ let (c, err) = call(&mut s, "execute_command", json!({"command": "render.preRender", "params": {"comp": "A", "output": "Lossless"}}));+ assert!(err, "a template output should be refused too: {c:?}");+ assert!(c[0]["text"].as_str().unwrap_or_default().contains("the project has no file yet"), "{c:?}");let queue = call_json(&mut s, "execute_command", json!({"command": "renderQueue.list"}));assert_eq!(queue["items"].as_array().map(Vec::len), Some(0), "nothing was queued: {queue}");// Naming an output inside a write root is how it is done.