mirror of
git://git.proxmox.com/git/pve-common.git
synced 2024-12-22 21:33:47 +03:00
download file from url: simplify error handling
the top-level error handling ensures the temporary downloaded file gets removed in case of an error, so there is no need to also handle that when decompression fails.. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
bf8f0ca200
commit
a4df83987b
@ -2061,10 +2061,8 @@ sub download_file_from_url {
|
||||
die "cant open temporary file $tmp_decomp for decompresson: $!\n";
|
||||
}
|
||||
print "decompressing $tmp_download to $tmp_decomp\n";
|
||||
eval { run_command($cmd, output => '>&'.fileno($fh)); };
|
||||
my $err = $@;
|
||||
run_command($cmd, output => '>&'.fileno($fh));
|
||||
unlink $tmp_download;
|
||||
die "$err\n" if $err;
|
||||
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";
|
||||
|
Loading…
Reference in New Issue
Block a user