api: oci image pull: do not pull OCI image if file already exists

This ensures that the API call fails early, before pulling the OCI image
from the registry and then failing to rename the temporary file.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
Link: https://lore.proxmox.com/20251117171528.262443-3-f.schauer@proxmox.com
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Filip Schauer
2025-11-17 18:13:15 +01:00
committed by Thomas Lamprecht
parent fe3b2915f2
commit 0ed80aaf31

View File

@ -964,6 +964,8 @@ __PACKAGE__->register_method({
my $path = PVE::Storage::get_vztmpl_dir($cfg, $storage);
PVE::Storage::activate_storage($cfg, $storage);
die "refusing to override existing file '$filename'\n" if (-f "$path/$filename");
local $SIG{INT} = sub {
unlink "$path/$tmp_filename"
or warn "could not cleanup temporary file: $!"