]> source.dussan.org Git - nextcloud-server.git/commitdiff
use and cache root storage info if a share can't be resolved
authorRobin Appelman <robin@icewind.nl>
Fri, 22 Apr 2022 12:59:15 +0000 (14:59 +0200)
committerRobin Appelman <robin@icewind.nl>
Fri, 22 Apr 2022 13:29:27 +0000 (15:29 +0200)
as is a broken share will never be cached

Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/legacy/OC_Helper.php

index 68fb4311ef8d074a31e8b5365b906c5d6f06e273..0d1903007c27ea6ee677d96bba385e82a8cded30 100644 (file)
@@ -48,6 +48,7 @@ use OC\Files\Filesystem;
 use OCP\Files\Mount\IMountPoint;
 use OCP\ICacheFactory;
 use OCP\IUser;
+use Psr\Log\LoggerInterface;
 use Symfony\Component\Process\ExecutableFinder;
 
 /**
@@ -518,7 +519,6 @@ class OC_Helper {
                $sourceStorage = $storage;
                if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
                        $includeExtStorage = false;
-                       $sourceStorage = $storage->getSourceStorage();
                        $internalPath = $storage->getUnjailedPath($rootInfo->getInternalPath());
                } else {
                        $internalPath = $rootInfo->getInternalPath();
@@ -544,7 +544,19 @@ class OC_Helper {
                        /** @var \OC\Files\Storage\Wrapper\Quota $storage */
                        $quota = $sourceStorage->getQuota();
                }
-               $free = $sourceStorage->free_space($internalPath);
+               try {
+                       $free = $sourceStorage->free_space($internalPath);
+               } catch (\Exception $e) {
+                       if ($path === "") {
+                               throw $e;
+                       }
+                       /** @var LoggerInterface $logger */
+                       $logger = \OC::$server->get(LoggerInterface::class);
+                       $logger->warning("Error while getting quota info, using root quota", ['exception' => $e]);
+                       $rootInfo = self::getStorageInfo("");
+                       $memcache->set($cacheKey, $rootInfo, 5 * 60);
+                       return $rootInfo;
+               }
                if ($free >= 0) {
                        $total = $free + $used;
                } else {