Add debug tracing to helper routines
This commit is contained in:
parent
422a748724
commit
063331c34d
1 changed files with 18 additions and 3 deletions
19
stow.in
19
stow.in
|
@ -1112,9 +1112,11 @@ sub process_tasks {
|
||||||
#============================================================================
|
#============================================================================
|
||||||
sub is_a_link {
|
sub is_a_link {
|
||||||
my ($path) = @_;
|
my ($path) = @_;
|
||||||
|
debug(4, " is_a_link($path)");
|
||||||
|
|
||||||
if (exists $Link_Task_For{$path}) {
|
if (exists $Link_Task_For{$path}) {
|
||||||
my $action = $Link_Task_For{$path}->{'action'};
|
my $action = $Link_Task_For{$path}->{'action'};
|
||||||
|
debug(4, "is_a_link($path): task exists with action $action");
|
||||||
|
|
||||||
if ($action eq 'remove') {
|
if ($action eq 'remove') {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1129,6 +1131,7 @@ sub is_a_link {
|
||||||
elsif (-l $path) {
|
elsif (-l $path) {
|
||||||
# check if any of its parent are links scheduled for removal
|
# check if any of its parent are links scheduled for removal
|
||||||
# (need this for edge case during unfolding)
|
# (need this for edge case during unfolding)
|
||||||
|
debug(4, "is_a_link($path): is a real link");
|
||||||
my $parent = '';
|
my $parent = '';
|
||||||
for my $part (split m{/+}, $path) {
|
for my $part (split m{/+}, $path) {
|
||||||
$parent = join_paths($parent, $part);
|
$parent = join_paths($parent, $part);
|
||||||
|
@ -1140,6 +1143,7 @@ sub is_a_link {
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
debug(4, "is_a_link($path): returning false");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1156,9 +1160,11 @@ sub is_a_link {
|
||||||
#============================================================================
|
#============================================================================
|
||||||
sub is_a_dir {
|
sub is_a_dir {
|
||||||
my ($path) = @_;
|
my ($path) = @_;
|
||||||
|
debug(4, " is_a_dir($path)");
|
||||||
|
|
||||||
if (exists $Dir_Task_For{$path}) {
|
if (exists $Dir_Task_For{$path}) {
|
||||||
my $action = $Dir_Task_For{$path}->{'action'};
|
my $action = $Dir_Task_For{$path}->{'action'};
|
||||||
|
debug(4, "is_a_dir($path): task exists with action $action");
|
||||||
if ($action eq 'remove') {
|
if ($action eq 'remove') {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1181,8 +1187,10 @@ sub is_a_dir {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-d $path) {
|
if (-d $path) {
|
||||||
|
debug(4, "is_a_dir($path): real dir");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
debug(4, "is_a_dir($path): returning false");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1198,10 +1206,11 @@ sub is_a_dir {
|
||||||
#============================================================================
|
#============================================================================
|
||||||
sub is_a_node {
|
sub is_a_node {
|
||||||
my ($path) = @_;
|
my ($path) = @_;
|
||||||
|
debug(4, " is_a_node($path)");
|
||||||
|
|
||||||
if (exists $Link_Task_For{$path}) {
|
if (exists $Link_Task_For{$path}) {
|
||||||
my $action = $Link_Task_For{$path}->{'action'};
|
my $action = $Link_Task_For{$path}->{'action'};
|
||||||
|
debug(4, "is_a_node($path): link task exists with action $action");
|
||||||
if ($action eq 'remove') {
|
if ($action eq 'remove') {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1215,7 +1224,7 @@ sub is_a_node {
|
||||||
|
|
||||||
if (exists $Dir_Task_For{$path}) {
|
if (exists $Dir_Task_For{$path}) {
|
||||||
my $action = $Dir_Task_For{$path}->{'action'};
|
my $action = $Dir_Task_For{$path}->{'action'};
|
||||||
|
debug(4, "is_a_node($path): dir task exists with action $action");
|
||||||
if ($action eq 'remove') {
|
if ($action eq 'remove') {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1231,15 +1240,19 @@ sub is_a_node {
|
||||||
my $prefix = '';
|
my $prefix = '';
|
||||||
for my $part (split m{/+}, $path) {
|
for my $part (split m{/+}, $path) {
|
||||||
$prefix = join_paths($prefix, $part);
|
$prefix = join_paths($prefix, $part);
|
||||||
|
debug(4, "is_a_node($path): prefix $prefix");
|
||||||
if (exists $Link_Task_For{$prefix} and
|
if (exists $Link_Task_For{$prefix} and
|
||||||
$Link_Task_For{$prefix}->{'action'} eq 'remove') {
|
$Link_Task_For{$prefix}->{'action'} eq 'remove') {
|
||||||
|
debug(4, "is_a_node($path): link scheduled for removal");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-e $path) {
|
if (-e $path) {
|
||||||
|
debug(4, "is_a_node($path): really exists");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
debug(4, "is_a_node($path): returning false");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1257,6 +1270,7 @@ sub read_a_link {
|
||||||
|
|
||||||
if (exists $Link_Task_For{$path}) {
|
if (exists $Link_Task_For{$path}) {
|
||||||
my $action = $Link_Task_For{$path}->{'action'};
|
my $action = $Link_Task_For{$path}->{'action'};
|
||||||
|
debug(4, "read_a_link($path): task exists with action $action");
|
||||||
|
|
||||||
if ($action eq 'create') {
|
if ($action eq 'create') {
|
||||||
return $Link_Task_For{$path}->{'source'};
|
return $Link_Task_For{$path}->{'source'};
|
||||||
|
@ -1271,6 +1285,7 @@ sub read_a_link {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif (-l $path) {
|
elsif (-l $path) {
|
||||||
|
debug(4, "read_a_link($path): real link");
|
||||||
return readlink $path
|
return readlink $path
|
||||||
or error("Could not read link: $path");
|
or error("Could not read link: $path");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue