5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2025-01-03 09:17:36 +03:00

tools: download file: refactor rename call

by reusing the tmp_download variable for the decompression case too.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Dominik Csapak 2024-11-18 15:31:10 +01:00 committed by Thomas Lamprecht
parent 903d285751
commit d8582cd045

View File

@ -2146,10 +2146,10 @@ sub download_file_from_url {
print "decompressing $tmp_download to $tmp_decomp\n";
run_command($cmd, output => '>&'.fileno($fh));
unlink $tmp_download;
rename($tmp_decomp, $dest) or die "unable to rename temporary file: $!\n";
} else {
rename($tmp_download, $dest) or die "unable to rename temporary file: $!\n";
$tmp_download = $tmp_decomp;
}
rename($tmp_download, $dest) or die "unable to rename temporary file: $!\n";
};
if (my $err = $@) {
unlink $tmp_download or warn "could not cleanup temporary file: $!"