mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 17:23:59 -04:00
Merge pull request #32076 from nextcloud/cache-storage-info-failed-share
use and cache root storage info if a share can't be resolved
This commit is contained in:
commit
b7be8f5c22
2 changed files with 20 additions and 2 deletions
|
|
@ -47,6 +47,7 @@ use OCP\Files\NotPermittedException;
|
|||
use OCP\Files\StorageNotAvailableException;
|
||||
use OCP\Lock\ILockingProvider;
|
||||
use OCP\Lock\LockedException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Sabre\DAV\Exception\BadRequest;
|
||||
use Sabre\DAV\Exception\Locked;
|
||||
use Sabre\DAV\Exception\NotFound;
|
||||
|
|
@ -331,6 +332,8 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICol
|
|||
* @return array
|
||||
*/
|
||||
public function getQuotaInfo() {
|
||||
/** @var LoggerInterface $logger */
|
||||
$logger = \OC::$server->get(LoggerInterface::class);
|
||||
if ($this->quotaInfo) {
|
||||
return $this->quotaInfo;
|
||||
}
|
||||
|
|
@ -347,10 +350,13 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICol
|
|||
];
|
||||
return $this->quotaInfo;
|
||||
} catch (\OCP\Files\NotFoundException $e) {
|
||||
$logger->warning("error while getting quota into", ['exception' => $e]);
|
||||
return [0, 0];
|
||||
} catch (\OCP\Files\StorageNotAvailableException $e) {
|
||||
$logger->warning("error while getting quota into", ['exception' => $e]);
|
||||
return [0, 0];
|
||||
} catch (NotPermittedException $e) {
|
||||
$logger->warning("error while getting quota into", ['exception' => $e]);
|
||||
return [0, 0];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue