From a09523636029a7dde1f4270336a2349efeb4559f Mon Sep 17 00:00:00 2001 From: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com> Date: Thu, 23 Apr 2026 10:50:18 +0200 Subject: [PATCH] fix: track time spent in recursive markOrRun calls Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com> --- .../lib/Listener/SharesUpdatedListener.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/files_sharing/lib/Listener/SharesUpdatedListener.php b/apps/files_sharing/lib/Listener/SharesUpdatedListener.php index a6ea34d295f9b..b6f22c009a072 100644 --- a/apps/files_sharing/lib/Listener/SharesUpdatedListener.php +++ b/apps/files_sharing/lib/Listener/SharesUpdatedListener.php @@ -43,9 +43,11 @@ class SharesUpdatedListener implements IEventListener { private float $cutOffMarkTime; /** - * The total amount of time we've spent so far processing updates + * Timestamp marking the first time this listener was triggered, used to + * determine if we should update the share date immediately or just mark the + * users for refresh. */ - private float $updatedTime = 0.0; + private ?float $firstRun = null; private bool $inUpdate = false; public function __construct( @@ -134,14 +136,15 @@ public function handle(Event $event): void { } private function markOrRun(IUser $user, callable $callback): void { - $start = floatval($this->clock->now()->format('U.u')); - if ($this->cutOffMarkTime === -1.0 || $this->updatedTime < $this->cutOffMarkTime) { + $now = floatval($this->clock->now()->format('U.u')); + $this->firstRun ??= $now; + $elapsed = $now - $this->firstRun; + + if ($this->cutOffMarkTime === -1.0 && $elapsed < $this->cutOffMarkTime) { $callback(); } else { $this->markUserForRefresh($user); } - $end = floatval($this->clock->now()->format('U.u')); - $this->updatedTime += $end - $start; } private function updateOrMarkUser(IUser $user): void {