]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: Recalculate storage statistics on updating the quota
authorJulius Härtl <jus@bitgrid.net>
Thu, 16 Feb 2023 07:43:14 +0000 (08:43 +0100)
committerJulius Härtl (Rebase PR Action) <github@juliushaertl.de>
Mon, 6 Mar 2023 22:46:07 +0000 (22:46 +0000)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
apps/dav/lib/Connector/Sabre/Directory.php
apps/provisioning_api/lib/Controller/UsersController.php
lib/private/User/User.php
lib/private/legacy/OC_Helper.php

index f4b1ee62190f35dc4618dfa421e42092fab84be7..396cfc3417c7259e3a7cf5b0dd15f07896b9b89c 100644 (file)
@@ -35,7 +35,6 @@ namespace OCA\DAV\Connector\Sabre;
 use OC\Files\Mount\MoveableMount;
 use OC\Files\View;
 use OC\Metadata\FileMetadata;
-use OC\Metadata\MetadataGroup;
 use OCA\DAV\Connector\Sabre\Exception\FileLocked;
 use OCA\DAV\Connector\Sabre\Exception\Forbidden;
 use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
@@ -57,7 +56,6 @@ use Sabre\DAV\INode;
 use OCP\Share\IManager as IShareManager;
 
 class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuota, \Sabre\DAV\IMoveTarget, \Sabre\DAV\ICopyTarget {
-
        /**
         * Cached directory content
         * @var \OCP\Files\FileInfo[]
@@ -116,7 +114,6 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICol
                        // for chunked upload also updating a existing file is a "createFile"
                        // because we create all the chunks before re-assemble them to the existing file.
                        if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
-
                                // exit if we can't create a new file and we don't updatable existing file
                                $chunkInfo = \OC_FileChunking::decodeName($name);
                                if (!$this->fileView->isCreatable($this->path) &&
index 97d66acd2e0bba98fb2af247ffd235a514153867..1613561fbe1f78b41ee623a8d2c77da135d45ec4 100644 (file)
@@ -77,7 +77,6 @@ use OCP\User\Backend\ISetDisplayNameBackend;
 use Psr\Log\LoggerInterface;
 
 class UsersController extends AUserData {
-
        /** @var IURLGenerator */
        protected $urlGenerator;
        /** @var LoggerInterface */
@@ -374,7 +373,7 @@ class UsersController extends AUserData {
                                $group = $this->groupManager->get($groupid);
                                // Check if group exists
                                if ($group === null) {
-                                       throw new OCSException('Subadmin group does not exist',  102);
+                                       throw new OCSException('Subadmin group does not exist', 102);
                                }
                                // Check if trying to make subadmin of admin group
                                if ($group->getGID() === 'admin') {
@@ -1311,7 +1310,7 @@ class UsersController extends AUserData {
                }
                // Check if group exists
                if ($group === null) {
-                       throw new OCSException('Group does not exist',  102);
+                       throw new OCSException('Group does not exist', 102);
                }
                // Check if trying to make subadmin of admin group
                if ($group->getGID() === 'admin') {
index 2b975c290ba87e08b5516514e82bbb5280171e6b..2d80dbc7adf274f5be70d709f28531af5c449128 100644 (file)
@@ -529,6 +529,7 @@ class User implements IUser {
                        $this->config->setUserValue($this->uid, 'files', 'quota', $quota);
                        $this->triggerChange('quota', $quota, $oldQuota);
                }
+               \OC_Helper::clearStorageInfo('/' . $this->uid . '/files');
        }
 
        /**
index c2036c7b8635408778e271df84d37d3f52ba21c1..0004edf5b8f2396ba2f6ed6a8472dae350d58405 100644 (file)
@@ -620,6 +620,15 @@ class OC_Helper {
                ];
        }
 
+       public static function clearStorageInfo(string $absolutePath): void {
+               /** @var ICacheFactory $cacheFactory */
+               $cacheFactory = \OC::$server->get(ICacheFactory::class);
+               $memcache = $cacheFactory->createLocal('storage_info');
+               $cacheKey = Filesystem::normalizePath($absolutePath) . '::';
+               $memcache->remove($cacheKey . 'include');
+               $memcache->remove($cacheKey . 'exclude');
+       }
+
        /**
         * Returns whether the config file is set manually to read-only
         * @return bool