Skip to content

Commit

Permalink
Catch node for share not found
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Apr 2, 2021
1 parent 4bea123 commit 64a38cc
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions apps/files_sharing/lib/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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 [];
}
}
}

0 comments on commit 64a38cc

Please sign in to comment.