aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2024-07-01 16:52:23 +0200
committerJohn Molakvoæ <skjnldsv@users.noreply.github.com>2024-09-16 15:07:21 +0200
commit6674f790a9eb81570b887719d1e29b2c1bcbe7a6 (patch)
tree844c6b46adaf44846d02e77ee738f901825c4f6c /lib
parentcfed24cb0254caf570b2a520979a83435a677cc8 (diff)
downloadnextcloud-server-6674f790a9eb81570b887719d1e29b2c1bcbe7a6.tar.gz
nextcloud-server-6674f790a9eb81570b887719d1e29b2c1bcbe7a6.zip
fix(files): Ensure that the hash method does not return null
To match https://github.com/nextcloud/server/blob/beececf66068f57c416225efcde9b44ce5c2e835/lib/private/Files/View.php#L1050 - Fix https://github.com/nextcloud/server/issues/44110 Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Storage/Local.php11
-rw-r--r--lib/private/Files/Storage/Wrapper/Availability.php1
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index 811a000ad6f..ec4fd84ebe2 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -400,8 +400,15 @@ class Local extends \OC\Files\Storage\Common {
return $result;
}
- public function hash($type, $path, $raw = false) {
- return hash_file($type, $this->getSourcePath($path), $raw);
+ public function hash($type, $path, $raw = false): string|false {
+ /** @var string|false|null */
+ $hash = hash_file($type, $this->getSourcePath($path), $raw);
+
+ if ($hash === null) {
+ return false;
+ }
+
+ return $hash;
}
public function free_space($path) {
diff --git a/lib/private/Files/Storage/Wrapper/Availability.php b/lib/private/Files/Storage/Wrapper/Availability.php
index 149cbbaa33b..6bd622e1c1b 100644
--- a/lib/private/Files/Storage/Wrapper/Availability.php
+++ b/lib/private/Files/Storage/Wrapper/Availability.php
@@ -315,6 +315,7 @@ class Availability extends Wrapper {
return parent::hash($type, $path, $raw);
} catch (StorageNotAvailableException $e) {
$this->setUnavailable($e);
+ return false;
}
}