[pve-devel] Fwd: Re: applied: [PATCH v2 storage 2/2] fix #2226: allow broken symlinks to be deleted via API
Stefan Reiter
s.reiter at proxmox.com
Mon Jun 17 12:18:50 CEST 2019
Thanks for applying, will include a changelog next time.
> On June 17, 2019 at 11:55 AM Thomas Lamprecht <t.lamprecht at proxmox.com> wrote:
>
>
> On 6/17/19 11:05 AM, Stefan Reiter wrote:
> > Symlinks with a non-existing target fail Perls '-f' test and were thus
> > not deleteable via the API (failing with '$path does not exist').
> >
> > Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
> > ---
> >
> > Deleting intact symlinks deletes the symlink but leaves the file it
> > points to intact. This behaviour has not changed with this patch.
> >
> > PVE/Storage/Plugin.pm | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
> > index 255c643..e20acb3 100644
> > --- a/PVE/Storage/Plugin.pm
> > +++ b/PVE/Storage/Plugin.pm
> > @@ -689,8 +689,8 @@ sub free_image {
> > if (defined($format) && ($format eq 'subvol')) {
> > File::Path::remove_tree($path);
> > } else {
> > -
> > - if (! -f $path) {
> > +
> > + if (! (-f $path || -l $path)) {
>
> followed up with changing it to (-e $path) here, if the file
> is some special file and the user want's to delete it we're fine
> with that, if the unlink fails we give feedback too.
I just tested with '-e', it does not return true for a broken symlink.
It does however return true for directories, which I'm not sure should be
deleteable via the API? I think '-f' and '-l' are the better solution here.
>
> > warn "disk image '$path' does not exists\n";
> > return undef;
> > }
> >
>
(Sorry for double mail Thomas)
More information about the pve-devel
mailing list