summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-01-23 09:55:03 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-02-07 11:23:29 +0100
commitd9dbed91050e80ab15768c278a1aecdfc3a1efda (patch)
tree6b29c1164d64e22f06c426175d0195f1d412a4f0 /lib
parentff776a90b133fa113c29511a5a7983a7a1a8b73c (diff)
downloadnextcloud-server-d9dbed91050e80ab15768c278a1aecdfc3a1efda.tar.gz
nextcloud-server-d9dbed91050e80ab15768c278a1aecdfc3a1efda.zip
Fix psalm errors related to filesizes
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Storage/Common.php4
-rw-r--r--lib/private/Files/Storage/Wrapper/Availability.php3
-rw-r--r--lib/private/Files/Storage/Wrapper/Encryption.php2
-rw-r--r--lib/private/Files/Stream/Encryption.php6
-rwxr-xr-xlib/private/LargeFileHelper.php7
5 files changed, 11 insertions, 11 deletions
diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php
index 8b46df3df6e..22b2e8164fb 100644
--- a/lib/private/Files/Storage/Common.php
+++ b/lib/private/Files/Storage/Common.php
@@ -695,9 +695,9 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
$result = $this->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, true);
if ($result) {
if ($sourceStorage->is_dir($sourceInternalPath)) {
- $result = $result && $sourceStorage->rmdir($sourceInternalPath);
+ $result = $sourceStorage->rmdir($sourceInternalPath);
} else {
- $result = $result && $sourceStorage->unlink($sourceInternalPath);
+ $result = $sourceStorage->unlink($sourceInternalPath);
}
}
return $result;
diff --git a/lib/private/Files/Storage/Wrapper/Availability.php b/lib/private/Files/Storage/Wrapper/Availability.php
index 2d3d33ff024..661bf636711 100644
--- a/lib/private/Files/Storage/Wrapper/Availability.php
+++ b/lib/private/Files/Storage/Wrapper/Availability.php
@@ -451,6 +451,9 @@ class Availability extends Wrapper {
}
/**
+ * @template T of StorageNotAvailableException|null
+ * @param T $e
+ * @psalm-return (T is null ? void : never)
* @throws StorageNotAvailableException
*/
protected function setUnavailable(?StorageNotAvailableException $e): void {
diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php
index 7c453e95092..f66661a615f 100644
--- a/lib/private/Files/Storage/Wrapper/Encryption.php
+++ b/lib/private/Files/Storage/Wrapper/Encryption.php
@@ -134,7 +134,7 @@ 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
*/
- public function filesize(string $path): int|float {
+ public function filesize(string $path): false|int|float {
$fullPath = $this->getFullPath($path);
/** @var CacheEntry $info */
diff --git a/lib/private/Files/Stream/Encryption.php b/lib/private/Files/Stream/Encryption.php
index cebf7bafced..bcf0a10740b 100644
--- a/lib/private/Files/Stream/Encryption.php
+++ b/lib/private/Files/Stream/Encryption.php
@@ -143,8 +143,8 @@ class Encryption extends Wrapper {
* @param \OC\Encryption\Util $util
* @param \OC\Encryption\File $file
* @param string $mode
- * @param int $size
- * @param int $unencryptedSize
+ * @param int|float $size
+ * @param int|float $unencryptedSize
* @param int $headerSize
* @param bool $signed
* @param string $wrapper stream wrapper class
@@ -158,7 +158,7 @@ class Encryption extends Wrapper {
\OC\Files\Storage\Storage $storage,
\OC\Files\Storage\Wrapper\Encryption $encStorage,
\OC\Encryption\Util $util,
- \OC\Encryption\File $file,
+ \OC\Encryption\File $file,
$mode,
$size,
$unencryptedSize,
diff --git a/lib/private/LargeFileHelper.php b/lib/private/LargeFileHelper.php
index c726737a604..2b2fed4e9f1 100755
--- a/lib/private/LargeFileHelper.php
+++ b/lib/private/LargeFileHelper.php
@@ -184,13 +184,10 @@ class LargeFileHelper {
/**
* Returns the current mtime for $fullPath
- *
- * @param string $fullPath
- * @return int
*/
public function getFileMtime(string $fullPath): int {
try {
- $result = filemtime($fullPath);
+ $result = filemtime($fullPath) ?: -1;
} catch (\Exception $e) {
$result = - 1;
}
@@ -198,7 +195,7 @@ class LargeFileHelper {
if (\OCP\Util::isFunctionEnabled('exec')) {
$os = strtolower(php_uname('s'));
if (strpos($os, 'linux') !== false) {
- return $this->exec('stat -c %Y ' . escapeshellarg($fullPath));
+ return (int)($this->exec('stat -c %Y ' . escapeshellarg($fullPath)) ?? -1);
}
}
}