Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Automation: classify contour library load/save paths in the workspace sandbox (#4391)

vangel76b2f67ef31f15
diff --git a/crates/automation/src/workspace.rs b/crates/automation/src/workspace.rs
index 76a14c6e3..dc57990e3 100644
--- a/crates/automation/src/workspace.rs
+++ b/crates/automation/src/workspace.rs
@@ -362,12 +362,12 @@ fn preference_uses_ambient_filesystem(path: &str) -> bool {
fn command_uses_ambient_path(id: &str, params: &Value) -> bool {
match id {
- "brush.presets.importAbr" | "gradient.presets.importGrd" | "plugin.install" | "swatches.import" => {
+ "brush.presets.importAbr" | "gradient.presets.importGrd" | "plugin.install" | "swatches.import" | "layer.layerStyle.contours.load" => {
// `data` wins over `path` in these commands; any `path` without it reads the filesystem.
params.get("data").is_none() && params.get("path").is_some()
}
// With a `path` the file is written there; without one the bytes come back as `data`.
- "swatches.export" => params.get("path").is_some(),
+ "swatches.export" | "layer.layerStyle.contours.save" => params.get("path").is_some(),
"plugin.reload" => true,
_ => false,
}
@@ -762,6 +762,8 @@ mod tests {
("plugin.install", serde_json::json!({"path": " "})),
("swatches.import", serde_json::json!({"path": "/outside/set.aco"})),
("swatches.export", serde_json::json!({"path": "/outside/set.ase"})),
+ ("layer.layerStyle.contours.load", serde_json::json!({"path": "/outside/set.shc"})),
+ ("layer.layerStyle.contours.save", serde_json::json!({"path": "/outside/set.shc"})),
] {
assert!(authorize_engine_command(id, &params).is_err(), "{id}: {params}");
}
@@ -771,6 +773,8 @@ mod tests {
("plugin.install", serde_json::json!({"data": "QUJD"})),
("swatches.import", serde_json::json!({"data": "QUJD"})),
("swatches.export", serde_json::json!({"format": "ase"})),
+ ("layer.layerStyle.contours.load", serde_json::json!({"data": "QUJD"})),
+ ("layer.layerStyle.contours.save", serde_json::json!({"names": ["a"]})),
] {
assert!(authorize_engine_command(id, &params).is_ok(), "{id}: {params}");
}