Skip to content

Commit 0e974a9

Browse files
committed
fix: Address review comments
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent 4d18eb7 commit 0e974a9

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/Controller/BookmarkController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ private function _returnBookmarkAsArray(Bookmark $bookmark): array {
115115
* @throws \OCP\DB\Exception
116116
*/
117117
private function _getRootFolderId(): int {
118+
if ($this->rootFolderId !== null) {
119+
return $this->rootFolderId;
120+
}
118121
if ($this->authorizer->getToken() !== null) {
119122
try {
120123
$publicFolder = $this->publicFolderMapper->find($this->authorizer->getToken());

lib/Controller/FoldersController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public function __construct(
6161
* @throws \OCP\DB\Exception
6262
*/
6363
private function _getRootFolderId(): int {
64+
if ($this->rootFolderId !== null) {
65+
return $this->rootFolderId;
66+
}
6467
if ($this->authorizer->getToken() !== null) {
6568
try {
6669
$publicFolder = $this->publicFolderMapper->find($this->authorizer->getToken());
@@ -504,10 +507,11 @@ public function getFolders(int $root = -1, int $layers = -1): JSONResponse {
504507
$internalRoot = $this->toInternalFolderId($root);
505508
$folders = $this->treeMapper->getSubFolders($internalRoot, $layers, $root === -1 ? false : null);
506509
if ($root === -1) {
507-
foreach ($folders as $folder) {
510+
foreach ($folders as &$folder) {
508511
$folder['parent_folder'] = -1;
509512
}
510513
}
514+
unset($folder);
511515
$res = new JSONResponse(['status' => 'success', 'data' => $folders]);
512516
$res->addHeader('Cache-Control', 'no-cache, must-revalidate');
513517
$res->addHeader('Expires', 'Sat, 26 Jul 1997 05:00:00 GMT');

0 commit comments

Comments
 (0)