From e07c52eda81524945ede49a7cc76fde78fd4bc43 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sun, 16 Aug 2026 06:57:57 +0200 Subject: [PATCH 1/3] 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: -- 2.55.0 From 5230b44fa823797dc5698a688bed8038ae6f8521 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sun, 16 Aug 2026 06:57:17 +0200 Subject: [PATCH 2/3] lib.FileContext: Interpolate path in _is_dir() _is_dir() logs a DEBUG message when _stat() is not implemented and it must guess from the trailing slash whether a path is a directory. The second part of that message is a plain string rather than an f-string, so '{path}' is logged verbatim instead of the path. Make it an f-string so the path is interpolated. 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/FileContext.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/jw/pkg/lib/FileContext.py b/src/python/jw/pkg/lib/FileContext.py index 059152d7..2622e7e8 100644 --- a/src/python/jw/pkg/lib/FileContext.py +++ b/src/python/jw/pkg/lib/FileContext.py @@ -287,7 +287,7 @@ class FileContext(abc.ABC): DEBUG, ( f"{self.log_name} doesn't implement stat(), judging by trailing " - 'slash if {path} is a directory' + f'slash if {path} is a directory' ), ) return path[-1] == '/' -- 2.55.0 From f6372d321a32419b5d6017ef099e3aeb13d63cc5 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sun, 16 Aug 2026 07:00:41 +0200 Subject: [PATCH 3/3] lib.ExecContext: Fix error message in _put() _put() catches a failure of the remote command sequence and logs "Failed to get from ", a phrase copied over from the get() path. This path, however, pushes content, so the message describes the wrong operation. Log a put-oriented message instead. 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 adef74bc..55faf2c7 100644 --- a/src/python/jw/pkg/lib/ExecContext.py +++ b/src/python/jw/pkg/lib/ExecContext.py @@ -560,7 +560,7 @@ class ExecContext(Base): await self.erase(tmp_file) await self.close() except Exception as e: - msg = f'Failed to get {path} from {self.root} ({str(e)})' + msg = f'Failed to put content to {path} on {self.root} ({str(e)})' if throw: raise Exception(msg) log(ERR, msg) -- 2.55.0