Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

#1743: choose default names around protected overflow paths

Kristian Myram2112e553ec7e
diff --git a/crates/engine/src/output_guard.rs b/crates/engine/src/output_guard.rs
index 4ac67d8cb..654569558 100644
--- a/crates/engine/src/output_guard.rs
+++ b/crates/engine/src/output_guard.rs
@@ -621,18 +621,20 @@ impl Session {
let Ok(outputs) = self.outputs_of(item, None) else { break };
let mut in_the_way = false;
for (module, path) in &outputs {
- match self.check_output(&protected, module, path) {
- Ok(Some(_)) => in_the_way = true,
- Err(_) => {
- item.output.output = template;
- return;
- }
- Ok(None) => {}
- }
let Ok(paths) = self.write_paths(module, path) else {
item.output.output = template;
return;
};
+ for destination in &paths {
+ match self.check_output(&protected, module, destination) {
+ Ok(Some(_)) => in_the_way = true,
+ Err(_) => {
+ item.output.output = template;
+ return;
+ }
+ Ok(None) => {}
+ }
+ }
in_the_way |= paths.iter().any(|path| queue.clash(&self.write_of(module, path, false)).is_some());
}
if !in_the_way {
diff --git a/crates/engine/src/tests/render_overwrite.rs b/crates/engine/src/tests/render_overwrite.rs
index d1ca6e65a..6034c15e6 100644
--- a/crates/engine/src/tests/render_overwrite.rs
+++ b/crates/engine/src/tests/render_overwrite.rs
@@ -695,6 +695,19 @@ fn possible_storage_overflow_destinations_cannot_replace_footage() {
assert_eq!(f.read("overflow/Main.mp4"), SOURCE);
}
+#[test]
+fn default_names_avoid_protected_storage_overflow_destinations() {
+ let mut f = Fixture::new("overflow-protected-default");
+ f.comp("Main");
+ with_overflow(&mut f);
+ f.footage("overflow/Main.mp4");
+ f.add(json!({"storageOverflow": true}));
+ assert_eq!(f.output(0), f.path("Main_1.mp4"));
+ f.render(json!({})).unwrap();
+ assert_eq!(f.exported().len(), 1);
+ assert_eq!(f.read("overflow/Main.mp4"), SOURCE);
+}
+
/// After Effects numbers the second item of one composition (`Comp 1_1.mov`). A default output
/// name that another item of the queue already has is numbered the same way.
#[test]