From 0b09531dc66f6a82fd1db997ceff85b1407f01fa Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 21 Nov 2022 16:21:25 +0100 Subject: [PATCH] Don't use quota cache through user management When querying the free space through user management APIs, don't use the cached quota value. The latter is only there to accelerate PROPFINDs. Signed-off-by: Vincent Petry --- apps/provisioning_api/lib/Controller/AUserData.php | 2 +- lib/private/legacy/OC_Helper.php | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php index f2fbea7b04f90..0fc2bb6f0d3d0 100644 --- a/apps/provisioning_api/lib/Controller/AUserData.php +++ b/apps/provisioning_api/lib/Controller/AUserData.php @@ -245,7 +245,7 @@ protected function fillStorageInfo(string $userId): array { try { \OC_Util::tearDownFS(); \OC_Util::setupFS($userId); - $storage = OC_Helper::getStorageInfo('/'); + $storage = OC_Helper::getStorageInfo('/', null, true, false); $data = [ 'free' => $storage['free'], 'used' => $storage['used'], diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index b793029e1f1f6..3b409fd1d0406 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -457,10 +457,12 @@ public static function findBinaryPath(string $program): ?string { * * @param string $path * @param \OCP\Files\FileInfo $rootInfo (optional) + * @param bool $includeMountPoints whether to include mount points in the size calculation + * @param bool $useCache whether to use the cached quota values * @return array * @throws \OCP\Files\NotFoundException */ - public static function getStorageInfo($path, $rootInfo = null, $includeMountPoints = true) { + public static function getStorageInfo($path, $rootInfo = null, $includeMountPoints = true, $useCache = true) { /** @var ICacheFactory $cacheFactory */ $cacheFactory = \OC::$server->get(ICacheFactory::class); $memcache = $cacheFactory->createLocal('storage_info'); @@ -470,9 +472,11 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin $fullPath = Filesystem::getView()->getAbsolutePath($path); $cacheKey = $fullPath. '::' . ($includeMountPoints ? 'include' : 'exclude'); - $cached = $memcache->get($cacheKey); - if ($cached) { - return $cached; + if ($useCache) { + $cached = $memcache->get($cacheKey); + if ($cached) { + return $cached; + } } if (!$rootInfo) {