mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
CLI: say that the input-overwrite check guards against mistakes, not races
The paths are compared before the save reopens the output, so a link swapped in meanwhile is not caught (CodeRabbit nitpick on #7455). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
9eef6aa51e
commit
75fe81865f
1 file changed
+3
-1
@@ -244,7 +244,9 @@ fn automation_workspace(args: &Args) -> Result<AuthorizedWorkspace, String> {
|
||||
/// An output that is the input file itself, however it is spelt (relative, with `./`, through a
|
||||
/// hard or symbolic link), would replace the original, and a lossy re-encode can't be undone: it
|
||||
/// is refused unless `--in-place` asks for it, as `batch` refuses an `--out` that is its `--in`
|
||||
/// folder (#7437).
|
||||
/// folder (#7437). The paths are compared when the command starts and the save opens `output`
|
||||
/// again later, so another process swapping in a link meanwhile goes unnoticed: this guards
|
||||
/// against mistakes, it is not a security boundary.
|
||||
fn refuse_overwriting_input(a: &Args, input: &str, output: &str) -> R {
|
||||
if !a.has("--in-place") && photocraft_engine::file_cmds::same_file(input, output) {
|
||||
return Err(format!("{output} is the input file, so the result would replace the original: choose another output, or pass --in-place to overwrite it"));
|
||||
|
||||
Reference in new issue
Block a user