aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Node
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-04-27 09:56:05 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-04-27 09:56:05 +0200
commit546d94c3ec5b0cb06cc284dead0da98ee346fc81 (patch)
treef64015e26506776e16ce679e61f4e8571e92b7af /lib/private/Files/Node
parent5e96228eb1f7999a327dacab22055ec2aa8e28a3 (diff)
downloadnextcloud-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.php12
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) {