unstow_node: extract new unstow_valid_link() sub
This commit is contained in:
parent
1f752a3c94
commit
cc592bdc44
1 changed files with 35 additions and 29 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue