diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2021-08-09 19:30:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-09 19:30:12 +0200 |
commit | 5bd91eac318536847a1f0834e59f8cfd41efae5a (patch) | |
tree | b32fdcbe1093dce14417142f7d485362faf56883 /apps | |
parent | 67e6468b9e5a6fb30638158c7bd558307d5ff747 (diff) | |
parent | 9b128d823b816c71348f4580b2c00247ee8fa1ec (diff) | |
download | nextcloud-server-5bd91eac318536847a1f0834e59f8cfd41efae5a.tar.gz nextcloud-server-5bd91eac318536847a1f0834e59f8cfd41efae5a.zip |
Merge pull request #28013 from nextcloud/jitter-appstore-and-updater-server-pinging
Diffstat (limited to 'apps')
-rw-r--r-- | apps/updatenotification/lib/Notification/BackgroundJob.php | 27 | ||||
-rw-r--r-- | apps/updatenotification/tests/Notification/BackgroundJobTest.php | 4 |
2 files changed, 20 insertions, 11 deletions
diff --git a/apps/updatenotification/lib/Notification/BackgroundJob.php b/apps/updatenotification/lib/Notification/BackgroundJob.php index be02c9fa686..e7dc193df6c 100644 --- a/apps/updatenotification/lib/Notification/BackgroundJob.php +++ b/apps/updatenotification/lib/Notification/BackgroundJob.php @@ -60,17 +60,12 @@ class BackgroundJob extends TimedJob { /** @var string[] */ protected $users; - /** - * NotificationBackgroundJob constructor. - * - * @param IConfig $config - * @param IManager $notificationManager - * @param IGroupManager $groupManager - * @param IAppManager $appManager - * @param IClientService $client - * @param Installer $installer - */ - public function __construct(IConfig $config, IManager $notificationManager, IGroupManager $groupManager, IAppManager $appManager, IClientService $client, Installer $installer) { + public function __construct(IConfig $config, + IManager $notificationManager, + IGroupManager $groupManager, + IAppManager $appManager, + IClientService $client, + Installer $installer) { // Run once a day $this->setInterval(60 * 60 * 24); @@ -83,6 +78,16 @@ class BackgroundJob extends TimedJob { } protected function run($argument) { + if (\OC::$CLI && !$this->config->getSystemValueBool('debug', false)) { + try { + // Jitter the pinging of the updater server and the appstore a bit. + // Otherwise all Nextcloud installations are pinging the servers + // in one of 288 + sleep(random_int(1, 180)); + } catch (\Exception $e) { + } + } + $this->checkCoreUpdate(); $this->checkAppUpdates(); } diff --git a/apps/updatenotification/tests/Notification/BackgroundJobTest.php b/apps/updatenotification/tests/Notification/BackgroundJobTest.php index 43b22728d28..d4d7a543e56 100644 --- a/apps/updatenotification/tests/Notification/BackgroundJobTest.php +++ b/apps/updatenotification/tests/Notification/BackgroundJobTest.php @@ -107,6 +107,10 @@ class BackgroundJobTest extends TestCase { $job->expects($this->once()) ->method('checkAppUpdates'); + $this->config->method('getSystemValueBool') + ->with('debug', false) + ->willReturn(true); + self::invokePrivate($job, 'run', [null]); } |