Skip Menu |

This queue is for tickets about the File-Copy-Recursive CPAN distribution.

Report information
The Basics
Id: 22083
Status: resolved
Priority: 0/
Queue: File-Copy-Recursive

People
Owner: Nobody in particular
Requestors: jclark [...] globalmoxie.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.27
Fixed in: (no value)



Subject: "File exists" error in Windows
I encountered this peculiar issue in a Windows server using 0.27, although I haven't been able to duplicate it in other Windows servers. I suspect that this may be a fairly rare issue, but I'm submitting a suggested change to cover this case. This particular server reported directories above the web root as not existing (returned false for -d or -e on those directories). I've never seen this before but I'm guessing it's some type of security measure. In other words, even though -d is true here: C:\path\to\webroot ... -d returns false here: C:\path\to When F::C::R needs to create a new directory, its behavior (via pathmk) is to descend from the top of the directory tree, building the missing directories as it goes. However, in this particular configuration, the server misreports that the directories at the top of the tree do not exist. pathmk tries to create the "missing" directories, but this throws a "File exists" exception since the directory does in fact exist. Weird, huh? The following patch fixes the problem. Instead of looking for missing directories from the top of the directory tree, it looks for them from the bottom. Then, when it finds the first missing directory, it goes down from there. Here's my suggested replacement for pathmk: sub pathmk { my @parts = File::Spec->splitdir( shift() ); my $nofatal = shift; my $pth; #backup and find the last directory my $base = $parts[0] ? 0 : 1; my $zer = @parts - 1; while ( $zer >= $base ) { $pth = File::Spec->catdir( @parts[0 .. $zer] ); last if -d $pth; $zer--; } $zer = $base if $zer < $base; #go forward from last directory and build missing dirs for ( $zer .. @parts - 1 ) { $pth = File::Spec->catdir( @parts[0 .. $_] ); mkdir $pth or return if !-d $pth && !$nofatal; mkdir $pth if !-d $pth && $nofatal; } 1; } Thanks once again for a very useful module. All best, Josh Clark
Do you have any more information on the version of Perl and windows server versions? I hate to work around a bug that should be fixed by the OS or in perl if it is to blame. I'll add some POD in the next version to address this and ask for more info if they see this happen. On Fri Oct 13 11:08:26 2006, jclark@globalmoxie.com wrote: Show quoted text
> I encountered this peculiar issue in a Windows server using 0.27, > although I haven't been able to duplicate it in other Windows servers. I > suspect that this may be a fairly rare issue, but I'm submitting a > suggested change to cover this case. > > This particular server reported directories above the web root as not > existing (returned false for -d or -e on those directories). I've never > seen this before but I'm guessing it's some type of security measure. > > In other words, even though -d is true here: > C:\path\to\webroot > > ... -d returns false here: > C:\path\to > > When F::C::R needs to create a new directory, its behavior (via pathmk) > is to descend from the top of the directory tree, building the missing > directories as it goes. However, in this particular configuration, the > server misreports that the directories at the top of the tree do not > exist. pathmk tries to create the "missing" directories, but this throws > a "File exists" exception since the directory does in fact exist. > > Weird, huh? > > The following patch fixes the problem. Instead of looking for missing > directories from the top of the directory tree, it looks for them from > the bottom. Then, when it finds the first missing directory, it goes > down from there. > > Here's my suggested replacement for pathmk: > > sub pathmk { > my @parts = File::Spec->splitdir( shift() ); > my $nofatal = shift; > my $pth; > > #backup and find the last directory > my $base = $parts[0] ? 0 : 1; > my $zer = @parts - 1; > while ( $zer >= $base ) { > $pth = File::Spec->catdir( @parts[0 .. $zer] ); > last if -d $pth; > $zer--; > } > $zer = $base if $zer < $base; > > #go forward from last directory and build missing dirs > for ( $zer .. @parts - 1 ) { > $pth = File::Spec->catdir( @parts[0 .. $_] ); > mkdir $pth or return if !-d $pth && !$nofatal; > mkdir $pth if !-d $pth && $nofatal; > } > 1; > } > > Thanks once again for a very useful module. > > All best, > Josh Clark
Subject: Re: [rt.cpan.org #22083] "File exists" error in Windows
Date: Fri, 18 Apr 2008 12:46:26 +0200
To: bug-File-Copy-Recursive [...] rt.cpan.org
From: Josh Clark <jclark [...] globalmoxie.com>
Hi Daniel, Many thanks for your note. Show quoted text
> Do you have any more information on the version of Perl and windows > server versions?
I'm afraid that I don't have lots more info about that server; I do know that my customer was running Windows 2003 (not sure which Perl version). I haven't seen this issue pop up anywhere else on hundreds of other servers, so I think that this is likely a weird one-off issue that's specific to this particular server. I suspect that the issue was related to the fact that he was running Ensim Webppliance to host/ manage various domains on the server. My general understanding is that the software puts various blocks in place to prevent users in one site directory from writing to other users' directories, and I think that whatever magic they have in place for that might have been the cause of the false report that directories don't exist when they do. I think that adding something to the POD as you suggest is a good option, since I doubt this issue applies to many other potential users. Thanks again for all you do and for a very useful module. All best, Josh :: josh clark :: maker of the BIG MEDIUM CMS for web designers :: http://globalmoxie.com/ :: Blog: http://globalmoxie.com/blog/
On Fri Apr 18 06:47:04 2008, jclark@globalmoxie.com wrote: Show quoted text
> I suspect that the issue was > related to the fact that he was running Ensim Webppliance to host/ > manage various domains on the server. My general understanding is that > the software puts various blocks in place to prevent users in one site > directory from writing to other users' directories, and I think that > whatever magic they have in place for that might have been the cause > of the false report that directories don't exist when they do. > > I think that adding something to the POD as you suggest is a good > option, since I doubt this issue applies to many other potential users.
This will likely be addressed in rt 40498 since $! might = File Exists simply because that is what it was before the call and nothing caused $! to be changed to what it actually was