From 0c3324f478d54a062d3d27529c870c8f095d5cd3 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 10 Aug 2023 19:01:07 -0700 Subject: [PATCH 1/2] fix(updatenotification): Skip update check Signed-off-by: Christopher Ng (cherry picked from commit b63dbae68aa1b5430f186aee5fcce55db711abc4) --- apps/updatenotification/lib/Notification/BackgroundJob.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/updatenotification/lib/Notification/BackgroundJob.php b/apps/updatenotification/lib/Notification/BackgroundJob.php index 4889c931238bc..08142d5b00bcc 100644 --- a/apps/updatenotification/lib/Notification/BackgroundJob.php +++ b/apps/updatenotification/lib/Notification/BackgroundJob.php @@ -57,6 +57,11 @@ public function __construct( } protected function run($argument) { + // Do not check for updates if not connected to the internet + if (!$this->config->getSystemValueBool('has_internet_connection', true)) { + return; + } + if (\OC::$CLI && !$this->config->getSystemValueBool('debug', false)) { try { // Jitter the pinging of the updater server and the appstore a bit. From 6dc9438eeeb19b03f58c2e80249e58e663545fd9 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 10 Aug 2023 19:07:53 -0700 Subject: [PATCH 2/2] test(updatenotification): No internet Signed-off-by: Christopher Ng (cherry picked from commit de4bc44f956cf51bcd01fa3ac01fc8824dc05eda) --- .../tests/Notification/BackgroundJobTest.php | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/apps/updatenotification/tests/Notification/BackgroundJobTest.php b/apps/updatenotification/tests/Notification/BackgroundJobTest.php index df8b104e9ca87..d669a5832b494 100644 --- a/apps/updatenotification/tests/Notification/BackgroundJobTest.php +++ b/apps/updatenotification/tests/Notification/BackgroundJobTest.php @@ -112,9 +112,34 @@ public function testRun() { $job->expects($this->once()) ->method('checkAppUpdates'); + $this->config->expects($this->exactly(2)) + ->method('getSystemValueBool') + ->withConsecutive( + ['has_internet_connection', true], + ['debug', false], + ) + ->willReturnOnConsecutiveCalls( + true, + true, + ); + + self::invokePrivate($job, 'run', [null]); + } + + public function testRunNoInternet() { + $job = $this->getJob([ + 'checkCoreUpdate', + 'checkAppUpdates', + ]); + + $job->expects($this->never()) + ->method('checkCoreUpdate'); + $job->expects($this->never()) + ->method('checkAppUpdates'); + $this->config->method('getSystemValueBool') - ->with('debug', false) - ->willReturn(true); + ->with('has_internet_connection', true) + ->willReturn(false); self::invokePrivate($job, 'run', [null]); }