]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't use quota cache through user management 35313/head
authorVincent Petry <vincent@nextcloud.com>
Mon, 21 Nov 2022 15:21:25 +0000 (16:21 +0100)
committerVincent Petry <vincent@nextcloud.com>
Mon, 21 Nov 2022 22:47:10 +0000 (23:47 +0100)
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 <vincent@nextcloud.com>
apps/provisioning_api/lib/Controller/AUserData.php
lib/private/legacy/OC_Helper.php

index f2fbea7b04f90b5581ce9404bc7871a62038ee8a..0fc2bb6f0d3d0d12268b42371e500a99fc6331ea 100644 (file)
@@ -245,7 +245,7 @@ abstract class AUserData extends OCSController {
                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'],
index b7838c56ef0805270d44e763809b6f0ff0f1e41f..ba9ac13b21686e5d049b7c77d751e7d7ef250a5c 100644 (file)
@@ -485,10 +485,12 @@ class OC_Helper {
         *
         * @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');
@@ -498,9 +500,11 @@ class OC_Helper {
 
                $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) {