summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2023-05-16 09:27:11 +0200
committerGitHub <noreply@github.com>2023-05-16 09:27:11 +0200
commitffa490617023635ef915fdd3f6c77195f93a1e2b (patch)
tree78760e0bf82a30755a4cba280cd5240432e9f132 /lib
parent8c539100ec38b0e3106e84a83cf7cfbfac65f739 (diff)
parent988c03a0a5a71a57efa252cd1f4e757a27aa5755 (diff)
downloadnextcloud-server-ffa490617023635ef915fdd3f6c77195f93a1e2b.tar.gz
nextcloud-server-ffa490617023635ef915fdd3f6c77195f93a1e2b.zip
Merge pull request #38289 from nextcloud/backport/38196/stable26
[stable26] Get rid of more int casts in file size manipulations
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Cache/Cache.php13
-rw-r--r--lib/private/Files/Cache/HomeCache.php2
-rw-r--r--lib/private/Files/Cache/Scanner.php2
-rw-r--r--lib/private/Files/Cache/Wrapper/CacheJail.php2
-rw-r--r--lib/private/Files/Cache/Wrapper/CacheWrapper.php2
-rw-r--r--lib/private/Files/Storage/DAV.php5
-rw-r--r--lib/private/Files/Storage/Local.php3
7 files changed, 16 insertions, 13 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php
index 67faed7b31b..bf459b2ff86 100644
--- a/lib/private/Files/Cache/Cache.php
+++ b/lib/private/Files/Cache/Cache.php
@@ -60,6 +60,7 @@ use OCP\Files\Search\ISearchOperator;
use OCP\Files\Search\ISearchQuery;
use OCP\Files\Storage\IStorage;
use OCP\IDBConnection;
+use OCP\Util;
use Psr\Log\LoggerInterface;
/**
@@ -191,8 +192,8 @@ class Cache implements ICache {
$data['path'] = (string)$data['path'];
$data['fileid'] = (int)$data['fileid'];
$data['parent'] = (int)$data['parent'];
- $data['size'] = 0 + $data['size'];
- $data['unencrypted_size'] = 0 + ($data['unencrypted_size'] ?? 0);
+ $data['size'] = Util::numericToNumber($data['size']);
+ $data['unencrypted_size'] = Util::numericToNumber($data['unencrypted_size'] ?? 0);
$data['mtime'] = (int)$data['mtime'];
$data['storage_mtime'] = (int)$data['storage_mtime'];
$data['encryptedVersion'] = (int)$data['encrypted'];
@@ -882,7 +883,7 @@ class Cache implements ICache {
*
* @param string $path
* @param array $entry (optional) meta data of the folder
- * @return int
+ * @return int|float
*/
public function calculateFolderSize($path, $entry = null) {
$totalSize = 0;
@@ -903,13 +904,13 @@ class Cache implements ICache {
if ($rows) {
$sizes = array_map(function (array $row) {
- return (int)$row['size'];
+ return Util::numericToNumber($row['size']);
}, $rows);
$unencryptedOnlySizes = array_map(function (array $row) {
- return (int)$row['unencrypted_size'];
+ return Util::numericToNumber($row['unencrypted_size']);
}, $rows);
$unencryptedSizes = array_map(function (array $row) {
- return (int)(($row['unencrypted_size'] > 0) ? $row['unencrypted_size'] : $row['size']);
+ return Util::numericToNumber(($row['unencrypted_size'] > 0) ? $row['unencrypted_size'] : $row['size']);
}, $rows);
$sum = array_sum($sizes);
diff --git a/lib/private/Files/Cache/HomeCache.php b/lib/private/Files/Cache/HomeCache.php
index 6b6b94c3f20..cd6408a86f6 100644
--- a/lib/private/Files/Cache/HomeCache.php
+++ b/lib/private/Files/Cache/HomeCache.php
@@ -36,7 +36,7 @@ class HomeCache extends Cache {
*
* @param string $path
* @param array $entry (optional) meta data of the folder
- * @return int
+ * @return int|float
*/
public function calculateFolderSize($path, $entry = null) {
if ($path !== '/' and $path !== '' and $path !== 'files' and $path !== 'files_trashbin' and $path !== 'files_versions') {
diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php
index f7d1d105d83..42f8f1b375b 100644
--- a/lib/private/Files/Cache/Scanner.php
+++ b/lib/private/Files/Cache/Scanner.php
@@ -368,7 +368,7 @@ class Scanner extends BasicEmitter implements IScanner {
* @param int $folderId id for the folder to be scanned
* @param bool $lock set to false to disable getting an additional read lock during scanning
* @param array $data the data of the folder before (re)scanning the children
- * @return int the size of the scanned folder or -1 if the size is unknown at this stage
+ * @return int|float the size of the scanned folder or -1 if the size is unknown at this stage
*/
protected function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $folderId = null, $lock = true, array $data = []) {
if ($reuse === -1) {
diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php
index 628ca3ee0e0..9649ae3541b 100644
--- a/lib/private/Files/Cache/Wrapper/CacheJail.php
+++ b/lib/private/Files/Cache/Wrapper/CacheJail.php
@@ -240,7 +240,7 @@ class CacheJail extends CacheWrapper {
*
* @param string $path
* @param array $entry (optional) meta data of the folder
- * @return int
+ * @return int|float
*/
public function calculateFolderSize($path, $entry = null) {
if ($this->getCache() instanceof Cache) {
diff --git a/lib/private/Files/Cache/Wrapper/CacheWrapper.php b/lib/private/Files/Cache/Wrapper/CacheWrapper.php
index 2cd378ad23c..f6bb949f968 100644
--- a/lib/private/Files/Cache/Wrapper/CacheWrapper.php
+++ b/lib/private/Files/Cache/Wrapper/CacheWrapper.php
@@ -250,7 +250,7 @@ class CacheWrapper extends Cache {
*
* @param string $path
* @param array $entry (optional) meta data of the folder
- * @return int
+ * @return int|float
*/
public function calculateFolderSize($path, $entry = null) {
if ($this->getCache() instanceof Cache) {
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php
index 0c4a81b7491..84916f19ac0 100644
--- a/lib/private/Files/Storage/DAV.php
+++ b/lib/private/Files/Storage/DAV.php
@@ -50,6 +50,7 @@ use OCP\Files\StorageInvalidException;
use OCP\Files\StorageNotAvailableException;
use OCP\Http\Client\IClientService;
use OCP\ICertificateManager;
+use OCP\Util;
use Psr\Http\Message\ResponseInterface;
use Sabre\DAV\Client;
use Sabre\DAV\Xml\Property\ResourceType;
@@ -433,7 +434,7 @@ class DAV extends Common {
return FileInfo::SPACE_UNKNOWN;
}
if (isset($response['{DAV:}quota-available-bytes'])) {
- return (int)$response['{DAV:}quota-available-bytes'];
+ return Util::numericToNumber($response['{DAV:}quota-available-bytes']);
} else {
return FileInfo::SPACE_UNKNOWN;
}
@@ -587,7 +588,7 @@ class DAV extends Common {
}
return [
'mtime' => isset($response['{DAV:}getlastmodified']) ? strtotime($response['{DAV:}getlastmodified']) : null,
- 'size' => (int)($response['{DAV:}getcontentlength'] ?? 0),
+ 'size' => Util::numericToNumber($response['{DAV:}getcontentlength'] ?? 0),
];
} catch (\Exception $e) {
$this->convertException($e, $path);
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index a375a544300..6dad028155b 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -52,6 +52,7 @@ use OCP\Files\GenericFileException;
use OCP\Files\IMimeTypeDetector;
use OCP\Files\Storage\IStorage;
use OCP\IConfig;
+use OCP\Util;
use Psr\Log\LoggerInterface;
/**
@@ -422,7 +423,7 @@ class Local extends \OC\Files\Storage\Common {
if ($space === false || is_null($space)) {
return \OCP\Files\FileInfo::SPACE_UNKNOWN;
}
- return (int)$space;
+ return Util::numericToNumber($space);
}
public function search($query) {