]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(files): Ensure that the hash method does not return null
authorLouis Chemineau <louis@chmn.me>
Mon, 1 Jul 2024 14:52:23 +0000 (16:52 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Mon, 16 Sep 2024 15:18:02 +0000 (15:18 +0000)
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>
lib/private/Files/Storage/Local.php
lib/private/Files/Storage/Wrapper/Availability.php

index 8a8e570d50264e82f74708298a93c013042fb6ee..d3655d335432397159465224ee183f46aa811282 100644 (file)
@@ -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) {
index 693d943f0dc2846e7fb259508f0e2a6bcda878c1..bab43977b608f5f512634b4732633c2d04f466d5 100644 (file)
@@ -334,6 +334,7 @@ class Availability extends Wrapper {
                        return parent::hash($type, $path, $raw);
                } catch (StorageNotAvailableException $e) {
                        $this->setUnavailable($e);
+                       return false;
                }
        }