lib.ExecApp: Add class #76

Closed
Jan Lindemann wants to merge 17 commits from jan/feature/20260822-lib-execapp-add-class into master AGit
Showing only changes of commit 6e2f341b33 - Show all commits

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 <jan@janware.com>
Jan Lindemann 2026-08-16 06:57:57 +02:00
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -553,7 +553,7 @@ class ExecContext(Base):
for cmd in cmds: for cmd in cmds:
log(DEBUG, f'{self.log_name}: Running {pretty_cmd(cmd.cmd, wd)}') log(DEBUG, f'{self.log_name}: Running {pretty_cmd(cmd.cmd, wd)}')
ret = await __run(cmd.cmd, cmd_input = cmd.cmd_input) 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 return ret
finally: finally:
if tmp_file is not None: if tmp_file is not None: