diff options
author | provokateurin <kate@provokateurin.de> | 2024-10-22 13:19:18 +0200 |
---|---|---|
committer | provokateurin <kate@provokateurin.de> | 2024-11-25 10:27:31 +0100 |
commit | c378e7401703146dcbfaa2be78b2d68675fd6742 (patch) | |
tree | 87061a0da55b1dea92708a8c4763a52cd29f2bc5 /lib/private | |
parent | a978e0a806901588a008ac2b71d825aae7541322 (diff) | |
download | nextcloud-server-c378e7401703146dcbfaa2be78b2d68675fd6742.tar.gz nextcloud-server-c378e7401703146dcbfaa2be78b2d68675fd6742.zip |
feat(Share20\Manager): Return all shares on IShareOwnerlessMount
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Share20/Manager.php | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 4856c051307..da90b2183ae 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -17,6 +17,7 @@ use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountManager; +use OCP\Files\Mount\IShareOwnerlessMount; use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\HintException; @@ -1215,17 +1216,26 @@ class Manager implements IManager { throw new \Exception('non-shallow getSharesInFolder is no longer supported'); } - return array_reduce($providers, function ($shares, IShareProvider $provider) use ($userId, $node, $reshares) { - $newShares = $provider->getSharesInFolder($userId, $node, $reshares); - foreach ($newShares as $fid => $data) { - if (!isset($shares[$fid])) { - $shares[$fid] = []; - } + $isOwnerless = $node->getMountPoint() instanceof IShareOwnerlessMount; - $shares[$fid] = array_merge($shares[$fid], $data); + $shares = []; + foreach ($providers as $provider) { + if ($isOwnerless) { + foreach ($node->getDirectoryListing() as $childNode) { + $data = $provider->getSharesByPath($childNode); + $fid = $childNode->getId(); + $shares[$fid] ??= []; + $shares[$fid] = array_merge($shares[$fid], $data); + } + } else { + foreach ($provider->getSharesInFolder($userId, $node, $reshares) as $fid => $data) { + $shares[$fid] ??= []; + $shares[$fid] = array_merge($shares[$fid], $data); + } } - return $shares; - }, []); + } + + return $shares; } /** @@ -1244,7 +1254,11 @@ class Manager implements IManager { return []; } - $shares = $provider->getSharesBy($userId, $shareType, $path, $reshares, $limit, $offset); + if ($path?->getMountPoint() instanceof IShareOwnerlessMount) { + $shares = array_filter($provider->getSharesByPath($path), static fn (IShare $share) => $share->getShareType() === $shareType); + } else { + $shares = $provider->getSharesBy($userId, $shareType, $path, $reshares, $limit, $offset); + } /* * Work around so we don't return expired shares but still follow @@ -1288,7 +1302,12 @@ class Manager implements IManager { $offset += $added; // Fetch again $limit shares - $shares = $provider->getSharesBy($userId, $shareType, $path, $reshares, $limit, $offset); + if ($path?->getMountPoint() instanceof IShareOwnerlessMount) { + // We already fetched all shares, so end here + $shares = []; + } else { + $shares = $provider->getSharesBy($userId, $shareType, $path, $reshares, $limit, $offset); + } // No more shares means we are done if (empty($shares)) { |