Skip to content

Commit 6cdad2d

Browse files
Merge pull request #39806 from nextcloud/fix/update-check-no-internet
fix(updatenotification): Skip update check
2 parents 03f5bb6 + de4bc44 commit 6cdad2d

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

apps/updatenotification/lib/Notification/BackgroundJob.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ public function __construct(
5757
}
5858

5959
protected function run($argument) {
60+
// Do not check for updates if not connected to the internet
61+
if (!$this->config->getSystemValueBool('has_internet_connection', true)) {
62+
return;
63+
}
64+
6065
if (\OC::$CLI && !$this->config->getSystemValueBool('debug', false)) {
6166
try {
6267
// Jitter the pinging of the updater server and the appstore a bit.

apps/updatenotification/tests/Notification/BackgroundJobTest.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,34 @@ public function testRun() {
112112
$job->expects($this->once())
113113
->method('checkAppUpdates');
114114

115+
$this->config->expects($this->exactly(2))
116+
->method('getSystemValueBool')
117+
->withConsecutive(
118+
['has_internet_connection', true],
119+
['debug', false],
120+
)
121+
->willReturnOnConsecutiveCalls(
122+
true,
123+
true,
124+
);
125+
126+
self::invokePrivate($job, 'run', [null]);
127+
}
128+
129+
public function testRunNoInternet() {
130+
$job = $this->getJob([
131+
'checkCoreUpdate',
132+
'checkAppUpdates',
133+
]);
134+
135+
$job->expects($this->never())
136+
->method('checkCoreUpdate');
137+
$job->expects($this->never())
138+
->method('checkAppUpdates');
139+
115140
$this->config->method('getSystemValueBool')
116-
->with('debug', false)
117-
->willReturn(true);
141+
->with('has_internet_connection', true)
142+
->willReturn(false);
118143

119144
self::invokePrivate($job, 'run', [null]);
120145
}

0 commit comments

Comments
 (0)