From b66abe553c928ec9f979ed740954ea45b222c468 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 10 Apr 2026 20:15:24 +0200 Subject: [PATCH] fix: don't trigger recursive SharesUpdatedListener when share is moved on create Signed-off-by: Robin Appelman --- apps/files_sharing/lib/Listener/SharesUpdatedListener.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/files_sharing/lib/Listener/SharesUpdatedListener.php b/apps/files_sharing/lib/Listener/SharesUpdatedListener.php index f1a1d625a6c..a84159ce722 100644 --- a/apps/files_sharing/lib/Listener/SharesUpdatedListener.php +++ b/apps/files_sharing/lib/Listener/SharesUpdatedListener.php @@ -46,6 +46,7 @@ class SharesUpdatedListener implements IEventListener { * The total amount of time we've spent so far processing updates */ private float $updatedTime = 0.0; + private bool $inUpdate = false; public function __construct( private readonly IManager $shareManager, @@ -60,6 +61,11 @@ class SharesUpdatedListener implements IEventListener { } public function handle(Event $event): void { + // prevent recursive updates + if ($this->inUpdate) { + return; + } + // don't trigger the on-setup checks if this handler triggers an fs setup $oldState = $this->homeSetupListener->setDisabled(true); @@ -87,7 +93,9 @@ class SharesUpdatedListener implements IEventListener { foreach ($this->shareManager->getUsersForShare($share) as $user) { if ($share->getSharedBy() !== $user->getUID()) { $this->markOrRun($user, function () use ($user, $share) { + $this->inUpdate = true; $this->shareUpdater->updateForAddedShare($user, $share); + $this->inUpdate = false; }); // Share target validation might have changed the target, restore it for the next user $share->setTarget($shareTarget);