unstow_node: extract new unstow_link_node() sub
This commit is contained in:
parent
cc592bdc44
commit
42cc1d2e60
1 changed files with 39 additions and 33 deletions
|
@ -935,6 +935,35 @@ sub unstow_node {
|
|||
|
||||
# Does the target exist?
|
||||
if ($self->is_a_link($target)) {
|
||||
$self->unstow_link_node($package, $target, $path);
|
||||
}
|
||||
elsif (-e $target) {
|
||||
debug(4, 2, "Evaluate existing node: $target");
|
||||
if (-d $target) {
|
||||
$self->unstow_contents($package, $target, $source);
|
||||
|
||||
# This action may have made the parent directory foldable
|
||||
if (my $parent = $self->foldable($target)) {
|
||||
$self->fold_tree($target, $parent);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$self->conflict(
|
||||
'unstow',
|
||||
$package,
|
||||
"existing target is neither a link nor a directory: $target",
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
debug(2, 1, "$target did not exist to be unstowed");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
sub unstow_link_node {
|
||||
my $self = shift;
|
||||
my ($package, $target, $path) = @_;
|
||||
debug(4, 2, "Evaluate existing link: $target");
|
||||
|
||||
# Where is the link pointing?
|
||||
|
@ -968,29 +997,6 @@ sub unstow_node {
|
|||
debug(2, 0, "--- removing invalid link into a stow directory: $path");
|
||||
$self->do_unlink($target);
|
||||
}
|
||||
}
|
||||
elsif (-e $target) {
|
||||
debug(4, 2, "Evaluate existing node: $target");
|
||||
if (-d $target) {
|
||||
$self->unstow_contents($package, $target, $source);
|
||||
|
||||
# This action may have made the parent directory foldable
|
||||
if (my $parent = $self->foldable($target)) {
|
||||
$self->fold_tree($target, $parent);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$self->conflict(
|
||||
'unstow',
|
||||
$package,
|
||||
"existing target is neither a link nor a directory: $target",
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
debug(2, 1, "$target did not exist to be unstowed");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
sub unstow_valid_link {
|
||||
|
|
Loading…
Reference in a new issue