Add $level variable in stow_contents and stow_node

This variables is used to keep track of the current level in the source.
This commit is contained in:
ATuinDev 2020-05-25 22:21:31 +02:00
parent d4e413536e
commit a2db7a9c76
No known key found for this signature in database
GPG key ID: 30B13E03CCAB58B7

View file

@ -317,6 +317,7 @@ sub plan_stow {
$package,
'.',
$path, # source from target
0,
);
debug(2, "Planning stow of package $package... done");
$self->{action_count}++;
@ -368,10 +369,11 @@ sub within_target_do {
#============================================================================
sub stow_contents {
my $self = shift;
my ($stow_path, $package, $target, $source) = @_;
my ($stow_path, $package, $target, $source, $level) = @_;
# Remove leading .. from $source
my $path = join '/', map { ($_ eq '..') ? ( ) : $_ } (split m{/+}, $source);
# Remove leading $level times .. from $source
my $n = 0;
my $path = join '/', map { (++$n <= $level) ? ( ) : $_ } (split m{/+}, $source);
return if $self->should_skip_target_which_is_stow_dir($target);
@ -409,6 +411,7 @@ sub stow_contents {
$package,
$node_target, # target
join_paths($source, $node), # source
$level
);
}
}
@ -431,7 +434,7 @@ sub stow_contents {
#============================================================================
sub stow_node {
my $self = shift;
my ($stow_path, $package, $target, $source) = @_;
my ($stow_path, $package, $target, $source, $level) = @_;
my $path = join_paths($stow_path, $package, $target);
@ -501,12 +504,14 @@ sub stow_node {
$existing_package,
$target,
join_paths('..', $existing_source),
$level + 1,
);
$self->stow_contents(
$self->{stow_path},
$package,
$target,
join_paths('..', $source),
$level + 1,
);
}
else {
@ -533,6 +538,7 @@ sub stow_node {
$package,
$target,
join_paths('..', $source),
$level + 1,
);
}
else {
@ -556,6 +562,7 @@ sub stow_node {
$package,
$target,
join_paths('..', $source),
$level + 1,
);
}
else {
@ -742,10 +749,7 @@ sub unstow_node_orig {
#============================================================================
sub unstow_contents {
my $self = shift;
my ($stow_path, $package, $target, $source) = @_;
# Remove leading .. from $source
my $path = join '/', map { ($_ eq '..') ? ( ) : $_ } (split m{/+}, $source);
my ($stow_path, $package, $target, $path) = @_;
return if $self->should_skip_target_which_is_stow_dir($target);