On 1/24/19 2:58 PM, Christian Ebner wrote:
> Remove directories if they are empty after destroying a VM.
>
> Signed-off-by: Christian Ebner <[email protected]>
> ---
>
> Version 2:
> * Changed comment to suggested text
> * removed File::Basename:: prefix to dirname()
>
applied thanks! FYI, I reworded the commit message though, because this does not
only affects destroying a whole VM but also if you destroy all disk of a VM.
And moved the '#1941' bug tag from the mailing list tag to the actual commit
message subject.
> PVE/Storage/Plugin.pm | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
> index e0c2a4e..7dbb41d 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,11 @@ sub free_image {
>
> unlink($path) || die "unlink '$path' failed - $!\n";
> }
> +
> + # try to cleanup directory to not clutter storage with empty $vmid dirs
> if
> + # all images from a guest got deleted
> + my $dir = dirname($path);
> + rmdir($dir);
>
> return undef;
> }
>
_______________________________________________
pve-devel mailing list
[email protected]
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel