diff options
author | Julius Härtl <jus@bitgrid.net> | 2023-01-31 08:48:45 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2023-01-31 11:41:34 +0100 |
commit | 7cc9ba28a7e221e7e9f3723f3a6fb51ad57ea152 (patch) | |
tree | 48f6da0976cb032403f324ee5f5c327020b8e82c /apps/files_sharing/lib/Controller/ShareInfoController.php | |
parent | e7c9fdb1ac1765972b811d17556fdb74fa7a2051 (diff) | |
download | nextcloud-server-7cc9ba28a7e221e7e9f3723f3a6fb51ad57ea152.tar.gz nextcloud-server-7cc9ba28a7e221e7e9f3723f3a6fb51ad57ea152.zip |
perf(federation): Only request root share info for checking availability
Otherwise this would request a full recursive dirctory listing while the result is never being used
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/files_sharing/lib/Controller/ShareInfoController.php')
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareInfoController.php | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareInfoController.php b/apps/files_sharing/lib/Controller/ShareInfoController.php index b090e6efcf1..2b8373af1cd 100644 --- a/apps/files_sharing/lib/Controller/ShareInfoController.php +++ b/apps/files_sharing/lib/Controller/ShareInfoController.php @@ -65,7 +65,7 @@ class ShareInfoController extends ApiController { * @param ?string $dir * @return JSONResponse */ - public function info(string $t, ?string $password = null, ?string $dir = null) { + public function info(string $t, ?string $password = null, ?string $dir = null, int $depth = -1) { try { $share = $this->shareManager->getShareByToken($t); } catch (ShareNotFound $e) { @@ -96,28 +96,32 @@ class ShareInfoController extends ApiController { } } - return new JSONResponse($this->parseNode($node, $permissionMask)); + return new JSONResponse($this->parseNode($node, $permissionMask, $depth)); } - private function parseNode(Node $node, int $permissionMask) { + private function parseNode(Node $node, int $permissionMask, int $depth) { if ($node instanceof File) { return $this->parseFile($node, $permissionMask); } - return $this->parseFolder($node, $permissionMask); + return $this->parseFolder($node, $permissionMask, $depth); } private function parseFile(File $file, int $permissionMask) { return $this->format($file, $permissionMask); } - private function parseFolder(Folder $folder, int $permissionMask) { + private function parseFolder(Folder $folder, int $permissionMask, int $depth) { $data = $this->format($folder, $permissionMask); + if ($depth === 0) { + return $data; + } + $data['children'] = []; $nodes = $folder->getDirectoryListing(); foreach ($nodes as $node) { - $data['children'][] = $this->parseNode($node, $permissionMask); + $data['children'][] = $this->parseNode($node, $permissionMask, $depth <= -1 ? -1 : $depth - 1); } return $data; |