Subject: | Net::xFTP::Foreign::isadir() to GlobalSCAPE EFT |
Net::xFTP::Foreign::isadir() identifies directories by calling opendir()
on them and assuming that if this is successful, the given path must be
a directory.
However, when the remote SSH server is GlobalSCAPE EFT, calling
opendir() on a regular file causes it to open the parent directory. The
attached patch additionally calls stat() on the given path and checks
the type.
One would hope that a call to stat() on it's own would be sufficient,
but perhaps there's some SFTP server out there where this doesn't work
either, so it may be best to call both opendir() and stat().
Subject: | xFTP_Foreign.pm-isadir.patch |
--- xFTP_Foreign.pm~ Tue Nov 30 03:45:39 2010
+++ xFTP_Foreign.pm Mon Jan 16 16:38:51 2012
@@ -472,7 +472,12 @@
if (defined($ok) && $ok)
{
eval { $self->{xftp}->closedir($ok) };
- return 1;
+
+ my $stat = $self->{xftp}->stat($path);
+ if (defined($stat) && S_ISDIR($stat->perm))
+ {
+ return 1;
+ }
}
return 0;
}