lib.ExecApp: Add class #76
1 changed files with 1 additions and 1 deletions
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>
commit
6e2f341b33
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue