From 5d884a564cad379e5dc097f30bfc8fd51990a647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Saccoccio?= Date: Thu, 19 Oct 2023 22:50:35 +0300 Subject: [PATCH] fix: check that share is a folder before trying to acces sub-folders --- lib/Controller/FoldersController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Controller/FoldersController.php b/lib/Controller/FoldersController.php index 3a742f0b..aa758b49 100644 --- a/lib/Controller/FoldersController.php +++ b/lib/Controller/FoldersController.php @@ -21,8 +21,14 @@ class FoldersController extends GenericApiController public function sub(string $folder): Http\Response { return Util::guardEx(function () use ($folder) { + $share = $this->fs->getShareNode(); + if ($share instanceof Folder) { + $rootNode = $share; + } else { + $rootNode = Util::getUserFolder(); + } + try { - $rootNode = $this->fs->getShareNode() ?? Util::getUserFolder(); $node = $rootNode->get($folder); } catch (\OCP\Files\NotFoundException) { throw Exceptions::NotFound('Folder not found');