From 64a38cc2b72afbbe0c65795d06e006ba81e50627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Fri, 2 Apr 2021 15:44:14 +0200 Subject: [PATCH] Catch node for share not found MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files_sharing/lib/Cache.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index 3a6ade5a2ac36..a6f95b08afb9b 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -33,6 +33,7 @@ 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 @@ public function clear() { 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'; + $regex = '/' . str_replace('%', '.*', $pattern) . '/i'; - $data = $this->get(''); - if (preg_match($regex, $data->getName()) === 1) { - return [$data]; - } + $data = $this->get(''); + if (preg_match($regex, $data->getName()) === 1) { + return [$data]; + } - return []; + return []; + } catch (NotFoundException $e) { + // Node for share not found + return []; + } } }