diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-04-27 09:56:05 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-04-27 09:56:05 +0200 |
commit | 546d94c3ec5b0cb06cc284dead0da98ee346fc81 (patch) | |
tree | f64015e26506776e16ce679e61f4e8571e92b7af /lib/private/Files/Node | |
parent | 5e96228eb1f7999a327dacab22055ec2aa8e28a3 (diff) | |
download | nextcloud-server-546d94c3ec5b0cb06cc284dead0da98ee346fc81.tar.gz nextcloud-server-546d94c3ec5b0cb06cc284dead0da98ee346fc81.zip |
Fix file_get_content signatures to make it clear it can return false
In File::getContent, which must return a string, throw an Exception
instead of returning false.
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private/Files/Node')
-rw-r--r-- | lib/private/Files/Node/File.php | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/private/Files/Node/File.php b/lib/private/Files/Node/File.php index 27056efef72..b6cd6571651 100644 --- a/lib/private/Files/Node/File.php +++ b/lib/private/Files/Node/File.php @@ -46,14 +46,16 @@ class File extends Node implements \OCP\Files\File { /** * @return string * @throws NotPermittedException + * @throws GenericFileException * @throws LockedException */ public function getContent() { if ($this->checkPermissions(\OCP\Constants::PERMISSION_READ)) { - /** - * @var \OC\Files\Storage\Storage $storage; - */ - return $this->view->file_get_contents($this->path); + $content = $this->view->file_get_contents($this->path); + if ($content === false) { + throw new GenericFileException(); + } + return $content; } else { throw new NotPermittedException(); } @@ -62,7 +64,7 @@ class File extends Node implements \OCP\Files\File { /** * @param string|resource $data * @throws NotPermittedException - * @throws \OCP\Files\GenericFileException + * @throws GenericFileException * @throws LockedException */ public function putContent($data) { |