Fix psalm errors related to filesizes

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/36120/head
Côme Chilliet 2 years ago
parent ff776a90b1
commit d9dbed9105
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
  1. 4
      lib/private/Files/Storage/Common.php
  2. 3
      lib/private/Files/Storage/Wrapper/Availability.php
  3. 2
      lib/private/Files/Storage/Wrapper/Encryption.php
  4. 4
      lib/private/Files/Stream/Encryption.php
  5. 7
      lib/private/LargeFileHelper.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;

@ -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 {

@ -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 */

@ -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

@ -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);
}
}
}

Loading…
Cancel
Save