api: oci image pull: unconditionally unlink temporary file on interrupt

It's more robust and cheaper to just always unlink (always one
syscall) and ignore ENOENT compared to stat and optional unlink (two
syscalls worst case).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht
2025-11-17 21:45:24 +01:00
parent 8ce79d86bb
commit c45b9b430a

View File

@ -977,8 +977,8 @@ __PACKAGE__->register_method({
local $SIG{INT} = sub { local $SIG{INT} = sub {
unlink "$path/$tmp_filename" unlink "$path/$tmp_filename"
or warn "could not cleanup temporary file: $!" or $!{ENOENT}
if -e "$path/$tmp_filename"; or warn "could not cleanup temporary file: $!";
die "got interrupted by signal\n"; die "got interrupted by signal\n";
}; };