Skip to content

Commit

Permalink
[VD:LocalFileSystem] fix Studio-42#1565 dose not support volume optio…
Browse files Browse the repository at this point in the history
…n `searchTimeout`
  • Loading branch information
nao-pon committed Aug 4, 2016
1 parent c735903 commit db66281
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions php/elFinderVolumeLocalFileSystem.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,16 @@ protected function doSearch($path, $q, $mimes) {
// 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(
Expand All @@ -1199,6 +1208,10 @@ protected function doSearch($path, $q, $mimes) {
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;
Expand All @@ -1209,10 +1222,13 @@ protected function doSearch($path, $q, $mimes) {
}
} 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
Expand All @@ -1228,8 +1244,8 @@ protected function doSearch($path, $q, $mimes) {
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;
Expand Down

0 comments on commit db66281

Please sign in to comment.