read_a_link: improve variable names
$path is horribly vague, so rename to $link to be more informative. Also the use of "$target" to describe a link's destination is very confusing in the context of Stow for reasons explained in the manual. So rename to $link_dest.
This commit is contained in:
parent
79f90d39b3
commit
1b597999e2
1 changed files with 16 additions and 16 deletions
|
@ -2029,45 +2029,45 @@ sub is_a_node {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
=head2 read_a_link($path)
|
=head2 read_a_link($link)
|
||||||
|
|
||||||
Return the source of a current or planned link
|
Return the destination of a current or planned link.
|
||||||
|
|
||||||
=over 4
|
=over 4
|
||||||
|
|
||||||
=item $path
|
=item $link
|
||||||
|
|
||||||
path to the link target
|
Path to the link target.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
Returns a string. Throws a fatal exception if the given path is not a
|
Returns the destination of the given link. Throws a fatal exception
|
||||||
current or planned link.
|
if the given path is not a current or planned link.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub read_a_link {
|
sub read_a_link {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($path) = @_;
|
my ($link) = @_;
|
||||||
|
|
||||||
if (my $action = $self->link_task_action($path)) {
|
if (my $action = $self->link_task_action($link)) {
|
||||||
debug(4, 1, "read_a_link($path): task exists with action $action");
|
debug(4, 1, "read_a_link($link): task exists with action $action");
|
||||||
|
|
||||||
if ($action eq 'create') {
|
if ($action eq 'create') {
|
||||||
return $self->{link_task_for}{$path}->{source};
|
return $self->{link_task_for}{$link}->{source};
|
||||||
}
|
}
|
||||||
elsif ($action eq 'remove') {
|
elsif ($action eq 'remove') {
|
||||||
internal_error(
|
internal_error(
|
||||||
"read_a_link() passed a path that is scheduled for removal: $path"
|
"read_a_link() passed a path that is scheduled for removal: $link"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif (-l $path) {
|
elsif (-l $link) {
|
||||||
debug(4, 1, "read_a_link($path): real link");
|
debug(4, 1, "read_a_link($link): real link");
|
||||||
my $target = readlink $path or error("Could not read link: $path ($!)");
|
my $link_dest = readlink $link or error("Could not read link: $link ($!)");
|
||||||
return $target;
|
return $link_dest;
|
||||||
}
|
}
|
||||||
internal_error("read_a_link() passed a non link path: $path\n");
|
internal_error("read_a_link() passed a non-link path: $link\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
=head2 do_link($link_dest, $link_src)
|
=head2 do_link($link_dest, $link_src)
|
||||||
|
|
Loading…
Reference in a new issue