diff options
author | Louis Chemineau <louis@chmn.me> | 2024-07-01 16:52:23 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2024-09-16 15:18:02 +0000 |
commit | 41111e5f0aba99ad0f151e7ff4994fd6f168b24b (patch) | |
tree | 78edda74b37fab5ea4876ea8d882f69733e33436 | |
parent | 440d8ea4b30111f65bc01274d50ad28f87091b78 (diff) | |
download | nextcloud-server-41111e5f0aba99ad0f151e7ff4994fd6f168b24b.tar.gz nextcloud-server-41111e5f0aba99ad0f151e7ff4994fd6f168b24b.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>
-rw-r--r-- | lib/private/Files/Storage/Local.php | 11 | ||||
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Availability.php | 1 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 8a8e570d502..d3655d33543 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; } } |