summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-12-19 13:54:23 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-01-02 12:24:05 +0100
commit5421510b1218ca6eb1a9075b1ddd2fa0b3782454 (patch)
tree624b7a048d73f6ca72e6f74c37dab27feeb8f7f2 /lib/private
parent82397529ef15b589f1fb24054786ca1e92ef77fa (diff)
downloadnextcloud-server-5421510b1218ca6eb1a9075b1ddd2fa0b3782454.tar.gz
nextcloud-server-5421510b1218ca6eb1a9075b1ddd2fa0b3782454.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')
-rw-r--r--lib/private/Files/Storage/Wrapper/Quota.php17
-rw-r--r--lib/private/Files/Storage/Wrapper/Wrapper.php6
2 files changed, 11 insertions, 12 deletions
diff --git a/lib/private/Files/Storage/Wrapper/Quota.php b/lib/private/Files/Storage/Wrapper/Quota.php
index 130a184dab2..d6d0c107701 100644
--- a/lib/private/Files/Storage/Wrapper/Quota.php
+++ b/lib/private/Files/Storage/Wrapper/Quota.php
@@ -37,9 +37,7 @@ use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Storage\IStorage;
class Quota extends Wrapper {
- /**
- * @var int $quota
- */
+ /** @var int|float|null int on 64bits, float on 32bits for bigint */
protected $quota;
/**
@@ -60,7 +58,7 @@ class Quota extends Wrapper {
}
/**
- * @return quota value
+ * @return int|float quota value
*/
public function getQuota() {
return $this->quota;
@@ -68,7 +66,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)) {
@@ -96,7 +95,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->quota < 0 || strpos($path, 'cache') === 0 || strpos($path, 'uploads') === 0) {
@@ -124,7 +123,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) {
$free = $this->free_space($path);
@@ -164,7 +163,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);
@@ -178,7 +177,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 6bc66bf9c89..5a3fc7567c2 100644
--- a/lib/private/Files/Storage/Wrapper/Wrapper.php
+++ b/lib/private/Files/Storage/Wrapper/Wrapper.php
@@ -150,7 +150,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea
* The result for filesize when called on a folder is required to be 0
*
* @param string $path
- * @return int|bool
+ * @return int|float|bool
*/
public function filesize($path) {
return $this->getWrapperStorage()->filesize($path);
@@ -252,7 +252,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);
@@ -328,7 +328,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);