Skip to content
Closed
Prev Previous commit
Next Next commit
fix: Fix promotion of reshares from subsubfolders
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc authored and backportbot[bot] committed Dec 3, 2024
commit 15c138e0860f868bebbdc159c2a0e66b6c8fe63f
27 changes: 17 additions & 10 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1196,16 +1196,23 @@ protected function promoteReshares(IShare $share): void {
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) {
$sharesInFolder = $this->getSharesInFolder($userId, $node, false);

foreach ($sharesInFolder as $shares) {
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);

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;
}
Expand Down