Remove directories if they are empty after destroying a VM.

Signed-off-by: Christian Ebner <c.eb...@proxmox.com>
---
 PVE/Storage/Plugin.pm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index e0c2a4e..00131df 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -5,6 +5,7 @@ use warnings;
 
 use File::chdir;
 use File::Path;
+use File::Basename;
 
 use PVE::Tools qw(run_command);
 use PVE::JSONSchema qw(get_standard_option);
@@ -689,6 +690,10 @@ sub free_image {
 
        unlink($path) || die "unlink '$path' failed - $!\n";
     }
+
+    # Clean up empty directories
+    my $dir = File::Basename::dirname($path);
+    rmdir($dir);
     
     return undef;
 }
-- 
2.11.0

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to