diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-12-19 13:54:23 +0100 |
---|---|---|
committer | MichaIng <micha@dietpi.com> | 2023-04-01 14:20:24 +0200 |
commit | ed863fb47c1ecdd5c47ade2a5634f14470406790 (patch) | |
tree | a8f5776c2b9bbc1a1ce48087b35a9ee70e8e961a /lib/private/Files/Storage/Wrapper | |
parent | c6b683342eefa7cbf41872a4873f6f5b356113fa (diff) | |
download | nextcloud-server-ed863fb47c1ecdd5c47ade2a5634f14470406790.tar.gz nextcloud-server-ed863fb47c1ecdd5c47ade2a5634f14470406790.zip |
Make it clear that file sizes may be float on 32bits
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private/Files/Storage/Wrapper')
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Quota.php | 16 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Wrapper.php | 4 |
2 files changed, 11 insertions, 9 deletions
diff --git a/lib/private/Files/Storage/Wrapper/Quota.php b/lib/private/Files/Storage/Wrapper/Quota.php index e28df24111e..5b702890675 100644 --- a/lib/private/Files/Storage/Wrapper/Quota.php +++ b/lib/private/Files/Storage/Wrapper/Quota.php @@ -41,7 +41,8 @@ use OCP\Files\Storage\IStorage; class Quota extends Wrapper { /** @var callable|null */ protected $quotaCallback; - protected ?int $quota; + /** @var int|float|null int on 64bits, float on 32bits for bigint */ + protected $quota; protected string $sizeRoot; private SystemConfig $config; @@ -57,7 +58,7 @@ class Quota extends Wrapper { } /** - * @return quota value + * @return int|float quota value */ public function getQuota() { if ($this->quota === null) { @@ -77,7 +78,8 @@ class Quota extends Wrapper { /** * @param string $path - * @param \OC\Files\Storage\Storage $storage + * @param IStorage $storage + * @return int|float */ protected function getSize($path, $storage = null) { if ($this->config->getValue('quota_include_external_storage', false)) { @@ -101,7 +103,7 @@ class Quota extends Wrapper { * Get free space as limited by the quota * * @param string $path - * @return int|bool + * @return int|float|bool */ public function free_space($path) { if (!$this->hasQuota()) { @@ -128,7 +130,7 @@ class Quota extends Wrapper { * * @param string $path * @param mixed $data - * @return int|false + * @return int|float|false */ public function file_put_contents($path, $data) { if (!$this->hasQuota()) { @@ -177,7 +179,7 @@ class Quota extends Wrapper { // don't apply quota for part files if (!$this->isPartFile($path)) { $free = $this->free_space($path); - if ($source && is_int($free) && $free >= 0 && $mode !== 'r' && $mode !== 'rb') { + if ($source && (is_int($free) || is_float($free)) && $free >= 0 && $mode !== 'r' && $mode !== 'rb') { // only apply quota for files, not metadata, trash or others if ($this->shouldApplyQuota($path)) { return \OC\Files\Stream\Quota::wrap($source, $free); @@ -192,7 +194,7 @@ class Quota extends Wrapper { * Checks whether the given path is a part file * * @param string $path Path that may identify a .part file - * @return string File path without .part extension + * @return bool * @note this is needed for reusing keys */ private function isPartFile($path) { diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index 26b4570cc75..c2d382f5dfc 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -249,7 +249,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea * * @param string $path * @param mixed $data - * @return int|false + * @return int|float|false */ public function file_put_contents($path, $data) { return $this->getWrapperStorage()->file_put_contents($path, $data); @@ -325,7 +325,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea * see https://www.php.net/manual/en/function.free_space.php * * @param string $path - * @return int|bool + * @return int|float|bool */ public function free_space($path) { return $this->getWrapperStorage()->free_space($path); |