Skip to content

Commit

Permalink
Allow Ftp::getMetadata() to work for directories.
Browse files Browse the repository at this point in the history
  • Loading branch information
twistor committed May 22, 2015
1 parent a1d15d4 commit 5901bb5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/Adapter/Ftp.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,19 @@ protected function createActualDirectory($directory, $connection)
public function getMetadata($path)
{
$listing = ftp_rawlist($this->getConnection(), $path);
if (!strlen($path)) {
return ['type' => 'dir', 'path' => ''];
}

$connection = $this->getConnection();

if (@ftp_chdir($connection, $path)) {
$this->setConnectionRoot();

return ['type' => 'dir', 'path' => $path];
}

$listing = ftp_rawlist($connection, $path);

if (empty($listing)) {
return false;
Expand Down
5 changes: 4 additions & 1 deletion tests/FtpTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ function ftp_login($connection)
return true;
}

function ftp_chdir($connection)
function ftp_chdir($connection, $directory)
{
if ($connection === 'chdir.fail') {
return false;
}
if ($directory === 'not.found') {
return false;
}

return true;
}
Expand Down

0 comments on commit 5901bb5

Please sign in to comment.