From 37df208bd778c223bfb47798e97fe35b0c1139bf Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 19 Nov 2020 09:14:29 +0100 Subject: [PATCH] Limit shared cache search if it is just a file Signed-off-by: Roeland Jago Douma --- apps/files_sharing/lib/Cache.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index dae33376f6d5c..c3f31ac3e4feb 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -177,4 +177,20 @@ private function getOwnerDisplayName() { public function clear() { // Not a valid action for Shared Cache } + + public function search($pattern) { + // Do the normal search on the whole storage for non files + 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 []; + } }