diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-01-20 18:02:45 +0100 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-02-07 11:23:28 +0100 |
commit | ff776a90b133fa113c29511a5a7983a7a1a8b73c (patch) | |
tree | 5a0493e0939477a082ae2d1811f94788efcd9a33 /lib/private/Files/Storage | |
parent | 2d8e696c24fef754662ed20f17b5b52091491ac5 (diff) | |
download | nextcloud-server-ff776a90b133fa113c29511a5a7983a7a1a8b73c.tar.gz nextcloud-server-ff776a90b133fa113c29511a5a7983a7a1a8b73c.zip |
Strong type filesize related methods to ease 32bits problem findings
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private/Files/Storage')
-rw-r--r-- | lib/private/Files/Storage/Common.php | 2 | ||||
-rw-r--r-- | lib/private/Files/Storage/FailedStorage.php | 2 | ||||
-rw-r--r-- | lib/private/Files/Storage/Local.php | 4 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Availability.php | 2 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Encoding.php | 5 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Encryption.php | 5 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Jail.php | 5 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Wrapper.php | 5 |
8 files changed, 9 insertions, 21 deletions
diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index 0c121feb11e..8b46df3df6e 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -121,7 +121,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { return $this->filetype($path) === 'file'; } - public function filesize($path) { + public function filesize(string $path): false|int|float { if ($this->is_dir($path)) { return 0; //by definition } else { diff --git a/lib/private/Files/Storage/FailedStorage.php b/lib/private/Files/Storage/FailedStorage.php index d748b3410c3..ae0c43ce1dc 100644 --- a/lib/private/Files/Storage/FailedStorage.php +++ b/lib/private/Files/Storage/FailedStorage.php @@ -80,7 +80,7 @@ class FailedStorage extends Common { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } - public function filesize($path) { + public function filesize(string $path): false|int|float { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 4b5154b207a..0bdbcb42d0f 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -242,14 +242,14 @@ class Local extends \OC\Files\Storage\Common { return $filetype; } - public function filesize($path) { + public function filesize(string $path): false|int|float { if (!$this->is_file($path)) { return 0; } $fullPath = $this->getSourcePath($path); if (PHP_INT_SIZE === 4) { $helper = new \OC\LargeFileHelper; - return $helper->getFileSize($fullPath); + return $helper->getFileSize($fullPath) ?? false; } return filesize($fullPath); } diff --git a/lib/private/Files/Storage/Wrapper/Availability.php b/lib/private/Files/Storage/Wrapper/Availability.php index a4a6fa0bd16..2d3d33ff024 100644 --- a/lib/private/Files/Storage/Wrapper/Availability.php +++ b/lib/private/Files/Storage/Wrapper/Availability.php @@ -165,7 +165,7 @@ class Availability extends Wrapper { } /** {@inheritdoc} */ - public function filesize($path) { + public function filesize(string $path): false|int|float { $this->checkAvailability(); try { return parent::filesize($path); diff --git a/lib/private/Files/Storage/Wrapper/Encoding.php b/lib/private/Files/Storage/Wrapper/Encoding.php index ed680f5045d..71587748931 100644 --- a/lib/private/Files/Storage/Wrapper/Encoding.php +++ b/lib/private/Files/Storage/Wrapper/Encoding.php @@ -210,11 +210,8 @@ class Encoding extends Wrapper { /** * see https://www.php.net/manual/en/function.filesize.php * The result for filesize when called on a folder is required to be 0 - * - * @param string $path - * @return int|bool */ - public function filesize($path) { + public function filesize(string $path): false|int|float { return $this->storage->filesize($this->findPathToUse($path)); } diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 0bd799507ff..7c453e95092 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -133,11 +133,8 @@ class Encryption extends Wrapper { /** * see https://www.php.net/manual/en/function.filesize.php * The result for filesize when called on a folder is required to be 0 - * - * @param string $path - * @return int */ - public function filesize($path) { + public function filesize(string $path): int|float { $fullPath = $this->getFullPath($path); /** @var CacheEntry $info */ diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php index 9834ae5a954..0f4101aad66 100644 --- a/lib/private/Files/Storage/Wrapper/Jail.php +++ b/lib/private/Files/Storage/Wrapper/Jail.php @@ -158,11 +158,8 @@ class Jail extends Wrapper { /** * see https://www.php.net/manual/en/function.filesize.php * The result for filesize when called on a folder is required to be 0 - * - * @param string $path - * @return int|bool */ - public function filesize($path) { + public function filesize(string $path): false|int|float { return $this->getWrapperStorage()->filesize($this->getUnjailedPath($path)); } diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index ed7e137fd88..345bf5fa2da 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -148,11 +148,8 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea /** * see https://www.php.net/manual/en/function.filesize.php * The result for filesize when called on a folder is required to be 0 - * - * @param string $path - * @return int|bool */ - public function filesize($path) { + public function filesize(string $path): false|int|float { return $this->getWrapperStorage()->filesize($path); } |