Replaces the current use without changes. The `$dir` variable is not used anymore at that moment so it is defined later.
Signed-off-by: Maximiliano Sandoval <m.sando...@proxmox.com> --- src/PVE/Storage/BTRFSPlugin.pm | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/PVE/Storage/BTRFSPlugin.pm b/src/PVE/Storage/BTRFSPlugin.pm index 8f4691b..7dec6e8 100644 --- a/src/PVE/Storage/BTRFSPlugin.pm +++ b/src/PVE/Storage/BTRFSPlugin.pm @@ -450,19 +450,16 @@ sub free_image { $subvol = raw_file_to_subvol($path); } - my $dir = dirname($subvol); - my $basename = basename($subvol); my @snapshot_vols; - foreach_subvol($dir, sub { - my ($volume, $name, $snapshot) = @_; - return if $name ne $basename; - return if !defined $snapshot; - push @snapshot_vols, "$dir/$volume"; + foreach_snapshot_of_subvol($subvol, sub { + my ($snap_name) = @_; + push @snapshot_vols, "$subvol\@$snap_name"; }); $class->btrfs_cmd(['subvolume', 'delete', '--', @snapshot_vols, $subvol]); # try to cleanup directory to not clutter storage with empty $vmid dirs if # all images from a guest got deleted + my $dir = dirname($subvol); rmdir($dir); return undef; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel