From e07c52eda81524945ede49a7cc76fde78fd4bc43 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sun, 16 Aug 2026 06:57:57 +0200 Subject: [PATCH] lib.ExecContext: Clean up temp file in _put() _put() writes the content into a temporary file with tee and, when atomic is set, moves it to the target path with a final mv. The loop over the command list sets tmp_file to None after each command, on the assumption stated in the comment that the file has been moved at that point - which is only true for the last command. When a chown, chmod, or mv after the tee fails, the finally block finds tmp_file is None and leaves the temporary file behind. Reset tmp_file only after all commands have completed, so that the finally block erases the temporary file whenever a step fails. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2 Signed-off-by: Jan Lindemann --- src/python/jw/pkg/lib/ExecContext.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/jw/pkg/lib/ExecContext.py b/src/python/jw/pkg/lib/ExecContext.py index 35685cc7..adef74bc 100644 --- a/src/python/jw/pkg/lib/ExecContext.py +++ b/src/python/jw/pkg/lib/ExecContext.py @@ -553,7 +553,7 @@ class ExecContext(Base): for cmd in cmds: log(DEBUG, f'{self.log_name}: Running {pretty_cmd(cmd.cmd, wd)}') ret = await __run(cmd.cmd, cmd_input = cmd.cmd_input) - tmp_file = None # Has been successfully moved at this point + tmp_file = None # All commands, including the final mv, succeeded return ret finally: if tmp_file is not None: