diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 77f67b3..efe73c7 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -284,6 +284,7 @@ sub plan_unstow { $self->{stow_path}, $package, '.', + $path, ); } debug(2, "Planning unstow of package $package... done"); @@ -369,7 +370,8 @@ sub stow_contents { my $self = shift; my ($stow_path, $package, $target, $source) = @_; - my $path = join_paths($stow_path, $package, $target); + # Remove leading .. from $source + my $path = join '/', map { ($_ eq '..') ? ( ) : $_ } (split m{/+}, $source); return if $self->should_skip_target_which_is_stow_dir($target); @@ -740,9 +742,10 @@ sub unstow_node_orig { #============================================================================ sub unstow_contents { my $self = shift; - my ($stow_path, $package, $target) = @_; + my ($stow_path, $package, $target, $source) = @_; - my $path = join_paths($stow_path, $package, $target); + # Remove leading .. from $source + my $path = join '/', map { ($_ eq '..') ? ( ) : $_ } (split m{/+}, $source); return if $self->should_skip_target_which_is_stow_dir($target); @@ -778,7 +781,7 @@ sub unstow_contents { $node_target = $adj_node_target; } - $self->unstow_node($stow_path, $package, $node_target); + $self->unstow_node($stow_path, $package, $node_target, join_paths($source, $node)); } if (-d $target) { $self->cleanup_invalid_links($target); @@ -798,7 +801,7 @@ sub unstow_contents { #============================================================================ sub unstow_node { my $self = shift; - my ($stow_path, $package, $target) = @_; + my ($stow_path, $package, $target, $source) = @_; my $path = join_paths($stow_path, $package, $target); @@ -872,7 +875,7 @@ sub unstow_node { elsif (-e $target) { debug(4, " Evaluate existing node: $target"); if (-d $target) { - $self->unstow_contents($stow_path, $package, $target); + $self->unstow_contents($stow_path, $package, $target, $source); # This action may have made the parent directory foldable if (my $parent = $self->foldable($target)) {