diff options
author | Anna Larch <anna@nextcloud.com> | 2023-08-17 10:19:10 +0200 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-08-27 14:04:44 +0000 |
commit | b3526ea81f39bec414eb76d78f6e1c00a279cb81 (patch) | |
tree | aac6e164ee3a8972a1fdf08a38f73fa64fff720f /apps/dav/lib | |
parent | 897c4d403700d8668c1df2f05837953c62aa2878 (diff) | |
download | nextcloud-server-b3526ea81f39bec414eb76d78f6e1c00a279cb81.tar.gz nextcloud-server-b3526ea81f39bec414eb76d78f6e1c00a279cb81.zip |
fix(CardDAV): only run upgrade sync if 1000 users or less
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/Command/SyncSystemAddressBook.php | 9 | ||||
-rw-r--r-- | apps/dav/lib/Migration/Version1027Date20230504122946.php | 21 |
2 files changed, 17 insertions, 13 deletions
diff --git a/apps/dav/lib/Command/SyncSystemAddressBook.php b/apps/dav/lib/Command/SyncSystemAddressBook.php index 272cca5a08e..86a9ea26b73 100644 --- a/apps/dav/lib/Command/SyncSystemAddressBook.php +++ b/apps/dav/lib/Command/SyncSystemAddressBook.php @@ -24,22 +24,18 @@ namespace OCA\DAV\Command; use OCA\DAV\CardDAV\SyncService; +use OCP\IConfig; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class SyncSystemAddressBook extends Command { - - /** @var SyncService */ - private $syncService; - /** * @param SyncService $syncService */ - public function __construct(SyncService $syncService) { + public function __construct(private SyncService $syncService, private IConfig $config) { parent::__construct(); - $this->syncService = $syncService; } protected function configure() { @@ -62,6 +58,7 @@ class SyncSystemAddressBook extends Command { $progress->finish(); $output->writeln(''); + $this->config->setAppValue('dav', 'needs_system_address_book_sync', 'no'); return 0; } } diff --git a/apps/dav/lib/Migration/Version1027Date20230504122946.php b/apps/dav/lib/Migration/Version1027Date20230504122946.php index be3d19e8a80..998be8111ca 100644 --- a/apps/dav/lib/Migration/Version1027Date20230504122946.php +++ b/apps/dav/lib/Migration/Version1027Date20230504122946.php @@ -29,6 +29,8 @@ namespace OCA\DAV\Migration; use Closure; use OCA\DAV\CardDAV\SyncService; use OCP\DB\ISchemaWrapper; +use OCP\IConfig; +use OCP\IUserManager; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; use Psr\Container\ContainerExceptionInterface; @@ -37,22 +39,27 @@ use Psr\Log\LoggerInterface; use Throwable; class Version1027Date20230504122946 extends SimpleMigrationStep { - private SyncService $syncService; - private LoggerInterface $logger; - - public function __construct(SyncService $syncService, LoggerInterface $logger) { - $this->syncService = $syncService; - $this->logger = $logger; - } + public function __construct(private SyncService $syncService, + private LoggerInterface $logger, + private IUserManager $userManager, + private IConfig $config) {} /** * @param IOutput $output * @param Closure(): ISchemaWrapper $schemaClosure * @param array $options */ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { + if($this->userManager->countUsers() > 1000) { + $this->config->setAppValue('dav', 'needs_system_address_book_sync', 'yes'); + $output->info('Could not sync system address books during update - too many user records have been found. Please call occ dav:sync-system-addressbook manually.'); + return; + } + try { $this->syncService->syncInstance(); + $this->config->setAppValue('dav', 'needs_system_address_book_sync', 'no'); } catch (Throwable $e) { + $this->config->setAppValue('dav', 'needs_system_address_book_sync', 'yes'); $this->logger->error('Could not sync system address books during update', [ 'exception' => $e, ]); |