mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
fix: prevent recursion in SharesUpdatedListener
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
858b0586e1
commit
48a23feb1a
1 changed files with 10 additions and 0 deletions
|
|
@ -29,6 +29,8 @@ use OCP\Share\IManager;
|
|||
* @template-implements IEventListener<UserAddedEvent|UserRemovedEvent|ShareCreatedEvent|ShareTransferredEvent|BeforeShareDeletedEvent|UserShareAccessUpdatedEvent>
|
||||
*/
|
||||
class SharesUpdatedListener implements IEventListener {
|
||||
private array $inUpdate = [];
|
||||
|
||||
public function __construct(
|
||||
private readonly IManager $shareManager,
|
||||
private readonly IUserMountCache $userMountCache,
|
||||
|
|
@ -57,6 +59,12 @@ class SharesUpdatedListener implements IEventListener {
|
|||
}
|
||||
|
||||
private function updateForUser(IUser $user): void {
|
||||
// prevent recursion
|
||||
if (isset($this->inUpdate[$user->getUID()])) {
|
||||
return;
|
||||
}
|
||||
$this->inUpdate[$user->getUID()] = true;
|
||||
|
||||
$cachedMounts = $this->userMountCache->getMountsForUser($user);
|
||||
$mountPoints = array_map(fn (ICachedMountInfo $mount) => $mount->getMountPoint(), $cachedMounts);
|
||||
$mountsByPath = array_combine($mountPoints, $cachedMounts);
|
||||
|
|
@ -71,5 +79,7 @@ class SharesUpdatedListener implements IEventListener {
|
|||
$this->shareTargetValidator->verifyMountPoint($user, $parentShare, $mountsByPath, $groupedShares);
|
||||
}
|
||||
}
|
||||
|
||||
unset($this->inUpdate[$user->getUID()]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue