diff options
Diffstat (limited to 'lib/private/legacy')
-rw-r--r-- | lib/private/legacy/OC_Helper.php | 20 | ||||
-rw-r--r-- | lib/private/legacy/OC_Util.php | 2 |
2 files changed, 13 insertions, 9 deletions
diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index b793029e1f1..de42a7bc7fc 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -95,7 +95,7 @@ class OC_Helper { /** * Make a computer file size * @param string $str file size in human readable format - * @return int|false a file size in bytes + * @return float|false a file size in bytes * * Makes 2kB to 2048. * @@ -104,7 +104,7 @@ class OC_Helper { public static function computerFileSize($str) { $str = strtolower($str); if (is_numeric($str)) { - return (int)$str; + return (float)$str; } $bytes_array = [ @@ -131,7 +131,7 @@ class OC_Helper { $bytes = round($bytes); - return (int)$bytes; + return $bytes; } /** @@ -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) { @@ -573,7 +577,7 @@ class OC_Helper { /** * Get storage info including all mount points and quota */ - private static function getGlobalStorageInfo(int $quota, IUser $user, IMountPoint $mount): array { + private static function getGlobalStorageInfo(float $quota, IUser $user, IMountPoint $mount): array { $rootInfo = \OC\Files\Filesystem::getFileInfo('', 'ext'); $used = $rootInfo['size']; if ($used < 0) { diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php index 88cd6baddc5..0130d503a89 100644 --- a/lib/private/legacy/OC_Util.php +++ b/lib/private/legacy/OC_Util.php @@ -158,7 +158,7 @@ class OC_Util { * Get the quota of a user * * @param IUser|null $user - * @return int|\OCP\Files\FileInfo::SPACE_UNLIMITED|false Quota bytes + * @return float|\OCP\Files\FileInfo::SPACE_UNLIMITED|false Quota bytes */ public static function getUserQuota(?IUser $user) { if (is_null($user)) { |