[pve-devel] [PATCH v2 storage 03/13] Add archive_remove

Fabian Ebner f.ebner at proxmox.com
Mon Jun 29 11:23:24 CEST 2020


On 6/15/20 2:01 PM, Thomas Lamprecht wrote:
> Am 6/10/20 um 1:23 PM schrieb Fabian Ebner:
>> to keep the removal of the archive and its log file together.
>>
>> Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
>> ---
>>
>> New in v2
>>
>>   PVE/Storage.pm | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/PVE/Storage.pm b/PVE/Storage.pm
>> index ac0dccd..a459572 100755
>> --- a/PVE/Storage.pm
>> +++ b/PVE/Storage.pm
>> @@ -1418,6 +1418,17 @@ 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;
> 
> please check the return value of unlinks, as it returns the number of actually deleted
> files you can here do:
> 
> unlink $archive_path or die "removing archive $archive_path failed: $!\n";
> 
>> +    unlink "$dirname/$logfn" if defined($logfn);
> 
> here too, but maybe we want to just warn or at least highlight that the archive
> was removed, just the log file wasn't.
> 

Ok.

>> +}
>> +
>>   sub extract_vzdump_config_tar {
>>       my ($archive, $conf_re) = @_;
>>   
>>
> 




More information about the pve-devel mailing list