From: Julius Härtl Date: Thu, 16 Feb 2023 07:43:14 +0000 (+0100) Subject: fix: Recalculate storage statistics on updating the quota X-Git-Tag: v27.0.0beta1~374^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3287eddbbc4465ee5fcb39016b3ad0ad27959ea6;p=nextcloud-server.git fix: Recalculate storage statistics on updating the quota Signed-off-by: Julius Härtl --- diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php index f4b1ee62190..396cfc3417c 100644 --- a/apps/dav/lib/Connector/Sabre/Directory.php +++ b/apps/dav/lib/Connector/Sabre/Directory.php @@ -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) && diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 97d66acd2e0..1613561fbe1 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -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') { diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 2b975c290ba..2d80dbc7adf 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -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'); } /** diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index c2036c7b863..0004edf5b8f 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -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