Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use and cache root storage info if a share can't be resolved #32076

Merged
merged 2 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
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;
Expand Down Expand Up @@ -331,6 +332,8 @@ public function delete() {
* @return array
*/
public function getQuotaInfo() {
/** @var LoggerInterface $logger */
$logger = \OC::$server->get(LoggerInterface::class);
if ($this->quotaInfo) {
return $this->quotaInfo;
}
Expand All @@ -347,10 +350,13 @@ public function getQuotaInfo() {
];
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];
}
}
Expand Down
16 changes: 14 additions & 2 deletions lib/private/legacy/OC_Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
use OCP\Files\Mount\IMountPoint;
use OCP\ICacheFactory;
use OCP\IUser;
use Psr\Log\LoggerInterface;
use Symfony\Component\Process\ExecutableFinder;

/**
Expand Down Expand Up @@ -518,7 +519,6 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin
$sourceStorage = $storage;
if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
$includeExtStorage = false;
$sourceStorage = $storage->getSourceStorage();
$internalPath = $storage->getUnjailedPath($rootInfo->getInternalPath());
} else {
$internalPath = $rootInfo->getInternalPath();
Expand All @@ -544,7 +544,19 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin
/** @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 {
Expand Down