fix: don't trigger on-setup share update from inside the share listener

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2026-04-09 19:08:02 +02:00
parent 1aa347dc76
commit cb8fb349d2
No known key found for this signature in database
GPG key ID: 42B69D8A64526EFB
3 changed files with 16 additions and 0 deletions

View file

@ -54,11 +54,15 @@ class SharesUpdatedListener implements IEventListener {
private readonly ClockInterface $clock,
private readonly LoggerInterface $logger,
IAppConfig $appConfig,
private readonly UserHomeSetupListener $homeSetupListener,
) {
$this->cutOffMarkTime = $appConfig->getValueFloat(Application::APP_ID, ConfigLexicon::UPDATE_CUTOFF_TIME, 3.0);
}
public function handle(Event $event): void {
// don't trigger the on-setup checks if this handler triggers an fs setup
$this->homeSetupListener->setDisabled(true);
if ($event instanceof UserShareAccessUpdatedEvent) {
foreach ($event->getUsers() as $user) {
$this->updateOrMarkUser($user);
@ -107,6 +111,8 @@ class SharesUpdatedListener implements IEventListener {
});
}
}
$this->homeSetupListener->setDisabled(false);
}
private function markOrRun(IUser $user, callable $callback): void {

View file

@ -23,16 +23,23 @@ use OCP\Files\Events\UserHomeSetupEvent;
* @template-implements IEventListener<UserHomeSetupEvent>
*/
class UserHomeSetupListener implements IEventListener {
private bool $disabled = false;
public function __construct(
private readonly ShareRecipientUpdater $updater,
private readonly IUserConfig $userConfig,
) {
}
public function setDisabled(bool $disabled): void {
$this->disabled = $disabled;
}
public function handle(Event $event): void {
if (!$event instanceof UserHomeSetupEvent) {
return;
}
if ($this->disabled) {
return;
}
$user = $event->getUser();
if ($this->userConfig->getValueBool($user->getUID(), Application::APP_ID, ConfigLexicon::USER_NEEDS_SHARE_REFRESH, true)) {

View file

@ -10,6 +10,7 @@ namespace OCA\Files_Sharing\Tests;
use OCA\Files_Sharing\Config\ConfigLexicon;
use OCA\Files_Sharing\Event\UserShareAccessUpdatedEvent;
use OCA\Files_Sharing\Listener\SharesUpdatedListener;
use OCA\Files_Sharing\Listener\UserHomeSetupListener;
use OCA\Files_Sharing\ShareRecipientUpdater;
use OCP\Config\IUserConfig;
use OCP\IAppConfig;
@ -57,6 +58,7 @@ class SharesUpdatedListenerTest extends \Test\TestCase {
return ($this->clockFn)();
});
$this->logger = $this->createMock(LoggerInterface::class);
$homeSetupListener = new UserHomeSetupListener($this->shareRecipientUpdater, $this->userConfig);
$this->sharesUpdatedListener = new SharesUpdatedListener(
$this->manager,
@ -65,6 +67,7 @@ class SharesUpdatedListenerTest extends \Test\TestCase {
$this->clock,
$this->logger,
$this->appConfig,
$homeSetupListener,
);
}