fix: check that share is a folder before trying to acces sub-folders

pull/880/head
Clément Saccoccio 2023-10-19 22:50:35 +03:00
parent c85a611651
commit 5d884a564c
1 changed files with 7 additions and 1 deletions

View File

@ -21,8 +21,14 @@ class FoldersController extends GenericApiController
public function sub(string $folder): Http\Response public function sub(string $folder): Http\Response
{ {
return Util::guardEx(function () use ($folder) { return Util::guardEx(function () use ($folder) {
$share = $this->fs->getShareNode();
if ($share instanceof Folder) {
$rootNode = $share;
} else {
$rootNode = Util::getUserFolder();
}
try { try {
$rootNode = $this->fs->getShareNode() ?? Util::getUserFolder();
$node = $rootNode->get($folder); $node = $rootNode->get($folder);
} catch (\OCP\Files\NotFoundException) { } catch (\OCP\Files\NotFoundException) {
throw Exceptions::NotFound('Folder not found'); throw Exceptions::NotFound('Folder not found');