From cc592bdc44599ea5b5c5b957c3411858680c21e3 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 1 Apr 2024 11:40:26 +0100 Subject: [PATCH] unstow_node: extract new unstow_valid_link() sub --- lib/Stow.pm.in | 64 +++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 4625fcf..bd7e8dd 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -962,35 +962,7 @@ sub unstow_node { # Does the existing $target actually point to anything? if (-e $existing_path) { - # Does link points to the right place? - - # Adjust for dotfile if necessary. - if ($self->{dotfiles}) { - $existing_path = adjust_dotfile($existing_path); - } - - if ($existing_path eq $path) { - $self->do_unlink($target); - } - - # XXX we quietly ignore links that are stowed to a different - # package. - - #elsif (defer($target)) { - # debug(2, 0, "--- deferring to installation of: $target"); - #} - #elsif ($self->override($target)) { - # debug(2, 0, "--- overriding installation of: $target"); - # $self->do_unlink($target); - #} - #else { - # $self->conflict( - # 'unstow', - # $package, - # "existing target is stowed to a different package: " - # . "$target => $existing_source" - # ); - #} + $self->unstow_valid_link($path, $target, $existing_path); } else { debug(2, 0, "--- removing invalid link into a stow directory: $path"); @@ -1021,6 +993,40 @@ sub unstow_node { return; } +sub unstow_valid_link { + my $self = shift; + my ($path, $target, $existing_path) = @_; + # Does link points to the right place? + + # Adjust for dotfile if necessary. + if ($self->{dotfiles}) { + $existing_path = adjust_dotfile($existing_path); + } + + if ($existing_path eq $path) { + $self->do_unlink($target); + } + + # XXX we quietly ignore links that are stowed to a different + # package. + + #elsif (defer($target)) { + # debug(2, 0, "--- deferring to installation of: $target"); + #} + #elsif ($self->override($target)) { + # debug(2, 0, "--- overriding installation of: $target"); + # $self->do_unlink($target); + #} + #else { + # $self->conflict( + # 'unstow', + # $package, + # "existing target is stowed to a different package: " + # . "$target => $existing_source" + # ); + #} +} + =head2 link_owned_by_package($target, $source) Determine whether the given link points to a member of a stowed