aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2024-07-01 16:52:23 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-09-16 15:16:56 +0000
commit3dc095255189b981487a0f416104838543b7f947 (patch)
tree269572f2258f02c72ed9ae3abe2550953e16ec18 /lib
parentb96802956ff27ed7df5db3a3231b8069b9cdd034 (diff)
downloadnextcloud-server-3dc095255189b981487a0f416104838543b7f947.tar.gz
nextcloud-server-3dc095255189b981487a0f416104838543b7f947.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 19e977c43f8..a9d91d16454 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -435,8 +435,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 693d943f0dc..bab43977b60 100644
--- a/lib/private/Files/Storage/Wrapper/Availability.php
+++ b/lib/private/Files/Storage/Wrapper/Availability.php
@@ -334,6 +334,7 @@ class Availability extends Wrapper {
return parent::hash($type, $path, $raw);
} catch (StorageNotAvailableException $e) {
$this->setUnavailable($e);
+ return false;
}
}