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 <vincent@nextcloud.com>
This commit is contained in:
Vincent Petry 2022-11-21 16:21:25 +01:00
parent d0c72cc11a
commit 0b09531dc6
No known key found for this signature in database
GPG key ID: E055D6A4D513575C
2 changed files with 9 additions and 5 deletions

View 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'],

View file

@ -457,10 +457,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');
@ -470,9 +472,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) {