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?
|
# Does the target exist?
|
||||||
if ($self->is_a_link($target)) {
|
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");
|
debug(4, 2, "Evaluate existing link: $target");
|
||||||
|
|
||||||
# Where is the link pointing?
|
# Where is the link pointing?
|
||||||
|
@ -969,29 +998,6 @@ sub unstow_node {
|
||||||
$self->do_unlink($target);
|
$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 {
|
sub unstow_valid_link {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
Loading…
Reference in a new issue