aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/legacy
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-08-15 18:31:10 +0200
committerRobin Appelman <robin@icewind.nl>2023-08-18 11:14:52 +0200
commit80b001f82eab9f96fd76fee817da9aadd42499c5 (patch)
treed2bb886138ab034a227b6e27d0f1b6003a78752d /lib/private/legacy
parent36f9ebb6776bf41f75599d7ff48826b204e29f6e (diff)
downloadnextcloud-server-80b001f82eab9f96fd76fee817da9aadd42499c5.tar.gz
nextcloud-server-80b001f82eab9f96fd76fee817da9aadd42499c5.zip
better caching in storage stats calculations
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/legacy')
-rw-r--r--lib/private/legacy/OC_Helper.php19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php
index d96cb7bb4e9..cf39d045ae9 100644
--- a/lib/private/legacy/OC_Helper.php
+++ b/lib/private/legacy/OC_Helper.php
@@ -69,6 +69,8 @@ use Psr\Log\LoggerInterface;
*/
class OC_Helper {
private static $templateManager;
+ private static ?ICacheFactory $cacheFactory = null;
+ private static ?bool $quotaIncludeExternalStorage = null;
/**
* Make a human file size
@@ -475,12 +477,15 @@ class OC_Helper {
* @throws \OCP\Files\NotFoundException
*/
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');
+ if (!self::$cacheFactory) {
+ self::$cacheFactory = \OC::$server->get(ICacheFactory::class);
+ }
+ $memcache = self::$cacheFactory->createLocal('storage_info');
// return storage info without adding mount points
- $includeExtStorage = \OC::$server->getSystemConfig()->getValue('quota_include_external_storage', false);
+ if (self::$quotaIncludeExternalStorage === null) {
+ self::$quotaIncludeExternalStorage = \OC::$server->getSystemConfig()->getValue('quota_include_external_storage', false);
+ }
$view = Filesystem::getView();
if (!$view) {
@@ -497,7 +502,7 @@ class OC_Helper {
}
if (!$rootInfo) {
- $rootInfo = \OC\Files\Filesystem::getFileInfo($path, $includeExtStorage ? 'ext' : false);
+ $rootInfo = \OC\Files\Filesystem::getFileInfo($path, self::$quotaIncludeExternalStorage ? 'ext' : false);
}
if (!$rootInfo instanceof \OCP\Files\FileInfo) {
throw new \OCP\Files\NotFoundException('The root directory of the user\'s files is missing');
@@ -512,9 +517,9 @@ class OC_Helper {
$storage = $mount->getStorage();
$sourceStorage = $storage;
if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
- $includeExtStorage = false;
+ self::$quotaIncludeExternalStorage = false;
}
- if ($includeExtStorage) {
+ if (self::$quotaIncludeExternalStorage) {
if ($storage->instanceOfStorage('\OC\Files\Storage\Home')
|| $storage->instanceOfStorage('\OC\Files\ObjectStore\HomeObjectStoreStorage')
) {