Merge pull request #24239 from nextcloud/backport/24203/stable20

[stable20] Use regex when searching on single file shares
This commit is contained in:
Roeland Jago Douma 2020-11-20 10:15:04 +01:00 committed by GitHub
commit 322b0ab2b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -177,4 +177,20 @@ class Cache extends CacheJail {
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 [];
}
}