summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2020-09-18 17:43:55 +0200
committerRobin Appelman <robin@icewind.nl>2023-04-05 14:44:55 +0200
commitb1f352c6149043d14256d6620d8b911eb28afae8 (patch)
tree9d06fbedc465a8e37483d23e044547a83577a28f /lib
parent59d0e7711dc84d46b30fd7a66ec13d8207b87150 (diff)
downloadnextcloud-server-b1f352c6149043d14256d6620d8b911eb28afae8.tar.gz
nextcloud-server-b1f352c6149043d14256d6620d8b911eb28afae8.zip
improve handling of files we can't access in the scanner
instead of erroring, remove the items from the cache. this situation can be triggered if a user has access to a file but looses it afterwards Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Cache/Scanner.php16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php
index f7d1d105d83..910b18b3e98 100644
--- a/lib/private/Files/Cache/Scanner.php
+++ b/lib/private/Files/Cache/Scanner.php
@@ -38,6 +38,7 @@ namespace OC\Files\Cache;
use Doctrine\DBAL\Exception;
use OCP\Files\Cache\IScanner;
use OCP\Files\ForbiddenException;
+use OCP\Files\NotFoundException;
use OCP\Files\Storage\IReliableEtagStorage;
use OCP\Lock\ILockingProvider;
use OC\Files\Storage\Wrapper\Encoding;
@@ -219,7 +220,7 @@ class Scanner extends BasicEmitter implements IScanner {
$newData['parent'] = $parentId;
$data['fileid'] = $this->addToCache($file, $newData, $fileId);
}
-
+
$data['oldSize'] = ($cacheData && isset($cacheData['size'])) ? $cacheData['size'] : 0;
if ($cacheData && isset($cacheData['encrypted'])) {
@@ -328,10 +329,15 @@ class Scanner extends BasicEmitter implements IScanner {
}
}
try {
- $data = $this->scanFile($path, $reuse, -1, null, $lock);
- if ($data && $data['mimetype'] === 'httpd/unix-directory') {
- $size = $this->scanChildren($path, $recursive, $reuse, $data['fileid'], $lock, $data);
- $data['size'] = $size;
+ try {
+ $data = $this->scanFile($path, $reuse, -1, null, $lock);
+ if ($data && $data['mimetype'] === 'httpd/unix-directory') {
+ $size = $this->scanChildren($path, $recursive, $reuse, $data['fileid'], $lock, $data);
+ $data['size'] = $size;
+ }
+ } catch (NotFoundException $e) {
+ $this->removeFromCache($path);
+ return null;
}
} finally {
if ($lock) {