drmuey / p5-File-Copy-Recursive

Perl extension for recursively copying files and directories
5 stars 12 forks source link

Behavior change in 0.39 breaks Dist::Zilla tests #5

Closed jmaslak closed 6 years ago

jmaslak commented 6 years ago

This test program (basically just the dircopy) exhibits different behavior on 0.38 vs. 0.39. on 0.38, foo_dst, foo_dst/a, and foo_dst/a/b is created and populated with bar.txt.

On 0.39, ./foo_dst isn't created at all.

#!/usr/bin/perl
# Sample code - foo_dst will not exist using 0.39.

use strict;
use warnings;
use File::Copy::Recursive qw(fcopy rcopy dircopy);

MAIN: {
    mkdir "foo_src";
    open my $fh, ">", "foo_src/bar.txt"; close $fh;

    my $src = "./foo_src";
    my $dst = "./foo_dst/a/b";
    dircopy($src, $dst);
}

At some point, a File::Spec::splitdir and File::Spec::catdir was changed to a File::Spec::splitpath and File::Spec::splitdir. I.E. I can get this to pass tests by simply changing:

lib/File/Copy/Recursive.pm

...
sub pathmk {
    my @parts   = File::Spec->splitpath( shift() );
    my $nofatal = shift;
    my $pth     = $parts[0];
    my $zer     = 0;
    if ( !$pth ) {
        $pth = File::Spec->catpath( $parts[0], $parts[1], '' );
        $zer = 1;
    }
    if ( !$pth ) {
        $pth = File::Spec->catpath( $parts[0], $parts[1], $parts[2] );
        $zer = 2;
    }
...

to:

sub pathmk {
    my @parts   = File::Spec->splitdir( shift() );
    my $nofatal = shift;
    my $pth     = $parts[0];
    my $zer     = 0;
    if ( !$pth ) {
        $pth = File::Spec->catdir( $parts[0], $parts[1], '' );
        $zer = 1;
    }
    if ( !$pth ) {
        $pth = File::Spec->catdir( $parts[0], $parts[1], $parts[2] );
        $zer = 2;
    }
...

Note the change from splitpath to splitdir and the change from catpath to catdir (x2).

I doubt that is the proper fix - I didn't spend a lot of time trying to figure out what the proper fix is, but I hope this can help you, and I'm thinking this is a bug in File::Copy::Recursive.

This is keeping installs of Dist::Zilla from installing (unless tests are disabled) if version 0.39 of F::C::R is installed.

I hope this gives you enough to go on to get this fixed. If you think it's actually a Dist::Zilla issue, just comment and I'll ping them over there.

Thanks, -- Joelle Maslak

abraxxa commented 6 years ago

This also breaks Catalyst::Devel by not installing catalyst files like everything in the root directory and the config files.

jmaslak commented 6 years ago

I've submitted a PR for this issue in pathmk.

drmuey commented 6 years ago

thanks!