Compare commits

...

1 Commits

Author SHA1 Message Date
John Molakvoæ (skjnldsv) 64a38cc2b7
Catch node for share not found
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
2021-04-02 15:46:30 +02:00
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 [];
}
}