From 68ce0b31e8a1b4004b4a8caa1c9ce6160b4aa71b Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Wed, 7 Apr 2021 12:25:37 +0200 Subject: [PATCH] prune backups: make vmid filtering more robust by relying on archive_info's vmid first. archive_info is already used to determine if it's a standard name, and in that case the vmid is certainly set. Also add asserts to make sure we got what we expected. Signed-off-by: Fabian Ebner --- PVE/Storage/Plugin.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index 05f1701..07eb88f 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -1233,9 +1233,9 @@ sub prune_backups { foreach my $backup (@{$backups}) { my $volid = $backup->{volid}; - my $backup_vmid = $backup->{vmid}; my $archive_info = eval { PVE::Storage::archive_info($volid) } // {}; my $backup_type = $archive_info->{type} // 'unknown'; + my $backup_vmid = $archive_info->{vmid} // $backup->{vmid}; next if defined($type) && $type ne $backup_type; @@ -1248,6 +1248,9 @@ sub prune_backups { $prune_entry->{vmid} = $backup_vmid if defined($backup_vmid); if ($archive_info->{is_std_name}) { + die "internal error - got no vmid\n" if !defined($backup_vmid); + die "internal error - got wrong vmid\n" if defined($vmid) && $backup_vmid ne $vmid; + $prune_entry->{ctime} = $archive_info->{ctime}; my $group = "$backup_type/$backup_vmid"; push @{$backup_groups->{$group}}, $prune_entry; -- 2.39.2