kenahoo / Path-Class

Cross-platform path specification manipulation
http://search.cpan.org/dist/Path-Class/
15 stars 28 forks source link

->move_to broken/inconsistent if destination is a directory. #50

Open hillu opened 6 years ago

hillu commented 6 years ago

Situation at start, on Debian GNU/Linux:

$ ls -ld /tmp/x /tmp/y
-rw-r--r-- 1 bengen bengen    0 Feb 26 15:18 /tmp/x
drwxr-xr-x 2 bengen bengen 4096 Feb 26 15:14 /tmp/y

Using Path::Class 0.37, doing something like

$x = file("/tmp/x"); $x->move_to("/tmp/y");

moves the file into the directory /tmp/y, so we end up with a file /tmp/y/x, but updates the Path::Class::File object like this:

VAR1 = bless( {
                 'file' => 'y',
                 'file_spec_class' => undef,
                 'dir' => bless( {
                                   'volume' => '',
                                   'file_spec_class' => undef,
                                   'dirs' => [
                                               '',
                                               'tmp'
                                             ]
                                 }, 'Path::Class::Dir' )
               }, 'Path::Class::File' );

I'd expect the operation to fail (like it would when using CORE::rename or POSIX::rename) or to update the name correctly.