Signed-off-by: Fabian Ebner <f.eb...@proxmox.com> --- Changes in v3: * die if unlink of archive fails * check whether log file exists before trying to unlink it * warn if unlink of log file fails
PVE/Storage.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/PVE/Storage.pm b/PVE/Storage.pm index ac0dccd..bab2ad6 100755 --- a/PVE/Storage.pm +++ b/PVE/Storage.pm @@ -1418,6 +1418,23 @@ sub archive_info { return $info; } +sub archive_remove { + my ($archive_path) = @_; + + my $dirname = dirname($archive_path); + my $archive_info = eval { archive_info($archive_path) } // {}; + my $logfn = $archive_info->{logfilename}; + + unlink $archive_path or die "removing archive $archive_path failed: $!\n"; + + if (defined($logfn)) { + my $logpath = "$dirname/$logfn"; + if (-e $logpath) { + unlink $logpath or warn "removing log file $logpath failed: $!\n"; + } + } +} + sub extract_vzdump_config_tar { my ($archive, $conf_re) = @_; -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel