]> git.proxmox.com Git - pve-storage.git/commitdiff
status: fix tmpfile cleanup
authorLorenz Stechauner <l.stechauner@proxmox.com>
Tue, 31 Aug 2021 10:16:32 +0000 (12:16 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 4 Oct 2021 08:22:06 +0000 (10:22 +0200)
$tmpfilename already gets unlinked after executing the cmd.

furthermore, because this is a local file, it is wrong to delete
it via the ssh command on a remote node.

small change: added \n to the error message.

Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
PVE/API2/Storage/Status.pm

index 6108ba1a7e33bfbe894ba9685b2fb35e72727cbc..02c970fb38968fd809ec57b171322b32d408b234 100644 (file)
@@ -459,7 +459,7 @@ __PACKAGE__->register_method ({
        # best effort to match apl_download behaviour
        chmod 0644, $tmpfilename;
 
-       my $err_cleanup = sub { unlink $dest, $tmpfilename; die "cleanup failed: $!" if $! && $! != ENOENT };
+       my $err_cleanup = sub { unlink $dest; die "cleanup failed: $!\n" if $! && $! != ENOENT };
 
        my $cmd;
        if ($node ne 'localhost' && $node ne PVE::INotify::nodename()) {
@@ -481,7 +481,7 @@ __PACKAGE__->register_method ({
  
            $cmd = ['/usr/bin/scp', @ssh_options, '-p', '--', $tmpfilename, "[$remip]:" . PVE::Tools::shell_quote($dest)];
 
-           $err_cleanup = sub { run_command([@remcmd, 'rm', '-f', '--', $dest, $tmpfilename]) };
+           $err_cleanup = sub { run_command([@remcmd, 'rm', '-f', '--', $dest]) };
        } else {
            PVE::Storage::activate_storage($cfg, $param->{storage});
            File::Path::make_path($dirname);