Skip to content

Commit

Permalink
fix(files): Ensure that the hash method does not return null
Browse files Browse the repository at this point in the history
  • Loading branch information
artonge committed Jul 2, 2024
1 parent beececf commit 3a61867
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/private/Files/Storage/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,15 @@ public function fopen($path, $mode) {
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) {
Expand Down
1 change: 1 addition & 0 deletions lib/private/Files/Storage/Wrapper/Availability.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ public function hash($type, $path, $raw = false) {
return parent::hash($type, $path, $raw);
} catch (StorageNotAvailableException $e) {
$this->setUnavailable($e);
return false;
}
}

Expand Down

0 comments on commit 3a61867

Please sign in to comment.