This commit is contained in:
John Molakvoæ 2021-06-02 18:57:49 +02:00 committed by GitHub
commit d81b55f015
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 11 deletions

View File

@ -33,6 +33,7 @@ use OC\Files\Cache\FailedCache;
use OC\Files\Cache\Wrapper\CacheJail;
use OC\Files\Storage\Wrapper\Jail;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\NotFoundException;
use OCP\Files\StorageNotAvailableException;
/**
@ -184,17 +185,22 @@ class Cache extends CacheJail {
public function search($pattern) {
// Do the normal search on the whole storage for non files
if ($this->storage->getItemType() !== 'file') {
return parent::search($pattern);
try {
if ($this->storage->getItemType() !== 'file') {
return parent::search($pattern);
}
$regex = '/' . str_replace('%', '.*', $pattern) . '/i';
$data = $this->get('');
if (preg_match($regex, $data->getName()) === 1) {
return [$data];
}
return [];
} catch (NotFoundException $e) {
// Node for share not found
return [];
}
$regex = '/' . str_replace('%', '.*', $pattern) . '/i';
$data = $this->get('');
if (preg_match($regex, $data->getName()) === 1) {
return [$data];
}
return [];
}
}