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:
Khawar Zamman WaniandClaude Opus 5.5 committed 2026-10-19 14:23:45 +05:30
1 parent 9eef6aa51e
commit 75fe81865f
1 file changed
+3 -1
+3 -1
View File
@@ -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"));