diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index 6e73547..31b8541 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -597,6 +597,12 @@ sub free_image { my $path = $class->filesystem_path($scfg, $volname); + if ($isBase) { + # try to remove immutable flag + eval { run_command(['/usr/bin/chattr', '-i', $path]); }; + warn $@ if $@; + } + if (defined($format) && ($format eq 'subvol')) { File::Path::remove_tree($path); } else { @@ -606,12 +612,6 @@ sub free_image { return undef; } - if ($isBase) { - # try to remove immutable flag - eval { run_command(['/usr/bin/chattr', '-i', $path]); }; - warn $@ if $@; - } - unlink($path) || die "unlink '$path' failed - $!\n"; }