diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-10-14 11:56:58 +0200 |
---|---|---|
committer | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2024-10-14 11:58:47 +0200 |
commit | e584e9baf744149649147cf45bab3c5218a31d4e (patch) | |
tree | 4a95c491d2722bce3bc0ad91e51e42237c2abade /lib | |
parent | 38f3d7e8c752f9fe71ea9c82aaefcf700a740319 (diff) | |
download | nextcloud-server-e584e9baf744149649147cf45bab3c5218a31d4e.tar.gz nextcloud-server-e584e9baf744149649147cf45bab3c5218a31d4e.zip |
fix: Fix promotion of reshares from subsubfolders
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Share20/Manager.php | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 52618d4e03e..5730f4f9635 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1082,16 +1082,23 @@ class Manager implements IManager { foreach ($userIds as $userId) { foreach ($shareTypes as $shareType) { $provider = $this->factory->getProviderForType($shareType); - $shares = $provider->getSharesBy($userId, $shareType, $node, false, -1, 0); - foreach ($shares as $child) { - $reshareRecords[] = $child; - } - } + if ($node instanceof Folder) { + /* We need to get all shares by this user to get subshares */ + $shares = $provider->getSharesBy($userId, $shareType, null, false, -1, 0); - if ($node instanceof Folder) { - $sharesInFolder = $this->getSharesInFolder($userId, $node, false); - - foreach ($sharesInFolder as $shares) { + foreach ($shares as $share) { + try { + $path = $share->getNode()->getPath(); + } catch (NotFoundException) { + /* Ignore share of non-existing node */ + continue; + } + if (str_starts_with($path, $node->getPath() . '/') || ($path === $node->getPath())) { + $reshareRecords[] = $share; + } + } + } else { + $shares = $provider->getSharesBy($userId, $shareType, $node, false, -1, 0); foreach ($shares as $child) { $reshareRecords[] = $child; } |