Merge branch '2.0-dsas'

This commit is contained in:
terrafrost 2018-08-18 15:04:51 -05:00
commit 6021e74a79
2 changed files with 37 additions and 1 deletions

View File

@ -866,7 +866,17 @@ class SFTP extends SSH2
unset($files[$key]);
continue;
}
if ($key != '.' && $key != '..' && is_array($this->query_stat_cache($this->realpath($dir . '/' . $key)))) {
$is_directory = false;
if ($key != '.' && $key != '..') {
if ($this->use_stat_cache) {
$is_directory = is_array($this->query_stat_cache($this->realpath($dir . '/' . $key)));
} else {
$stat = $this->lstat($dir . '/' . $key);
$is_directory = $stat && $stat['type'] === NET_SFTP_TYPE_DIRECTORY;
}
}
if ($is_directory) {
$depth++;
$files[$key] = $this->rawlist($dir . '/' . $key, true);
$depth--;

View File

@ -725,5 +725,31 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
$sftp->exec('ping google.com -c 5');
sleep(5);
$sftp->nlist();
return $sftp;
}
/**
* @depends testExecNlist
*/
public function testRawlistDisabledStatCache($sftp)
{
$this->assertTrue($sftp->mkdir(self::$scratchDir));
$this->assertTrue($sftp->chdir(self::$scratchDir));
$this->assertTrue($sftp->put('text.txt', 'zzzzz'));
$this->assertTrue($sftp->mkdir('subdir'));
$this->assertTrue($sftp->chdir('subdir'));
$this->assertTrue($sftp->put('leaf.txt', 'yyyyy'));
$this->assertTrue($sftp->chdir('../../'));
$list_cache_enabled = $sftp->rawlist('.', true);
$sftp->clearStatCache();
$sftp->disableStatCache();
$list_cache_disabled = $sftp->rawlist('.', true);
$this->assertEquals($list_cache_enabled, $list_cache_disabled, 'The files should be the same regardless of stat cache', 0.0, 10, true);
}
}