[VD:LocalFileSystem] fix #1565 dose not support volume option searchTimeout

This commit is contained in:
nao-pon
2016-08-04 14:37:41 +09:00
parent c73590336c
commit db66281569
+21 -5
View File
@@ -1182,7 +1182,16 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
// non UTF-8 use elFinderVolumeDriver::doSearch()
return parent::doSearch($path, $q, $mimes);
}
$result = array();
$timeout = $this->options['searchTimeout']? $this->searchStart + $this->options['searchTimeout'] : 0;
if ($timeout && $timeout < time()) {
$this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode($path)));
return $result;
}
elFinder::extendTimeLimit($this->options['searchTimeout'] + 30);
$match = array();
try {
$iterator = new RecursiveIteratorIterator(
@@ -1199,6 +1208,10 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
RecursiveIteratorIterator::CATCH_GET_CHILD
);
foreach ($iterator as $key => $node) {
if ($timeout && ($this->error || $timeout < time())) {
!$this->error && $this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode($node->getPath)));
break;
}
if ($node->isDir()) {
if ($this->stripos($node->getFilename(), $q) !== false) {
$match[] = $key;
@@ -1209,10 +1222,13 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
}
} catch (Exception $e) {}
$result = array();
if ($match) {
foreach($match as $p) {
if ($timeout && ($this->error || $timeout < time())) {
!$this->error && $this->setError(elFinder::ERROR_SEARCH_TIMEOUT, $this->path($this->encode(dirname($p))));
break;
}
$stat = $this->stat($p);
if (!$stat) { // invalid links
@@ -1228,8 +1244,8 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
if ((!$mimes || $stat['mime'] !== 'directory')) {
$stat['path'] = $this->path($stat['hash']);
if ($this->URL && !isset($stat['url'])) {
$path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1));
$stat['url'] = $this->URL . $path;
$_path = str_replace(DIRECTORY_SEPARATOR, '/', substr($p, strlen($this->root) + 1));
$stat['url'] = $this->URL . $_path;
}
$result[] = $stat;