From 7a66cb84dc7b632b7f81e9cfc85ee2991d2b1d4f Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 22 Nov 2022 15:39:00 +0100 Subject: [PATCH 1/3] Revert "[stable24] Fix quota type to int" Signed-off-by: Vincent Petry --- lib/private/legacy/OC_Helper.php | 6 +++--- lib/private/legacy/OC_Util.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index ba9ac13b21686..269922f21dd6c 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -95,7 +95,7 @@ public static function humanFileSize($bytes) { /** * Make a computer file size * @param string $str file size in human readable format - * @return int|false a file size in bytes + * @return float|bool a file size in bytes * * Makes 2kB to 2048. * @@ -104,7 +104,7 @@ public static function humanFileSize($bytes) { public static function computerFileSize($str) { $str = strtolower($str); if (is_numeric($str)) { - return (int)$str; + return (float)$str; } $bytes_array = [ @@ -131,7 +131,7 @@ public static function computerFileSize($str) { $bytes = round($bytes); - return (int)$bytes; + return $bytes; } /** diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php index 3a3b634e5228a..84416c2133743 100644 --- a/lib/private/legacy/OC_Util.php +++ b/lib/private/legacy/OC_Util.php @@ -158,7 +158,7 @@ public static function isDefaultExpireDateEnforced() { * Get the quota of a user * * @param IUser|null $user - * @return int|\OCP\Files\FileInfo::SPACE_UNLIMITED|false Quota bytes + * @return float Quota bytes */ public static function getUserQuota(?IUser $user) { if (is_null($user)) { From c73f11ba4de8ffb9cfe59c8c905a91a7a4c88d66 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 23 Nov 2022 11:24:53 +0100 Subject: [PATCH 2/3] Float the quota Signed-off-by: Vincent Petry --- lib/private/legacy/OC_Helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index 269922f21dd6c..cf3f157b8a711 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -605,7 +605,7 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin /** * 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) { From f8e18e5caa7fc79592f02cbf74399cc99b82a4c6 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 24 Nov 2022 20:55:50 +0100 Subject: [PATCH 3/3] Update baseline for some unrelated errors Signed-off-by: Vincent Petry --- build/psalm-baseline.xml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index da22e228cd4ec..c7e2974b16b6c 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -4404,7 +4404,8 @@ IImage|null - + + $quota $this->lastLogin @@ -4528,6 +4529,14 @@ \Test\Util\User\Dummy + + + OC_Helper::computerFileSize($userQuota) + + + float + + $this->request->server @@ -4625,4 +4634,12 @@ PreconditionNotMetException + + + \OC_Helper::computerFileSize($str) + + + float|false + +