aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2023-08-11 21:19:17 +0200
committerGitHub <noreply@github.com>2023-08-11 21:19:17 +0200
commit6cdad2d4cedfa9dbbdae22f57f9623e2ed3b1527 (patch)
tree91b401573860bf8e51cd65d87495b9e039c8d12a /apps
parent03f5bb68a33551d282c66072a940c8b906fc811b (diff)
parentde4bc44f956cf51bcd01fa3ac01fc8824dc05eda (diff)
downloadnextcloud-server-6cdad2d4cedfa9dbbdae22f57f9623e2ed3b1527.tar.gz
nextcloud-server-6cdad2d4cedfa9dbbdae22f57f9623e2ed3b1527.zip
Merge pull request #39806 from nextcloud/fix/update-check-no-internet
fix(updatenotification): Skip update check
Diffstat (limited to 'apps')
-rw-r--r--apps/updatenotification/lib/Notification/BackgroundJob.php5
-rw-r--r--apps/updatenotification/tests/Notification/BackgroundJobTest.php29
2 files changed, 32 insertions, 2 deletions
diff --git a/apps/updatenotification/lib/Notification/BackgroundJob.php b/apps/updatenotification/lib/Notification/BackgroundJob.php
index 4889c931238..08142d5b00b 100644
--- a/apps/updatenotification/lib/Notification/BackgroundJob.php
+++ b/apps/updatenotification/lib/Notification/BackgroundJob.php
@@ -57,6 +57,11 @@ class BackgroundJob extends TimedJob {
}
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.
diff --git a/apps/updatenotification/tests/Notification/BackgroundJobTest.php b/apps/updatenotification/tests/Notification/BackgroundJobTest.php
index df8b104e9ca..d669a5832b4 100644
--- a/apps/updatenotification/tests/Notification/BackgroundJobTest.php
+++ b/apps/updatenotification/tests/Notification/BackgroundJobTest.php
@@ -112,9 +112,34 @@ class BackgroundJobTest extends TestCase {
$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]);
}