Skip to content

Commit 96b88d3

Browse files
authored
Merge pull request nextcloud#43986 from nextcloud/backport/43972/stable27
[stable27] fix: Fetch custom app store url without internet connection
2 parents 9525868 + 0b1fcf0 commit 96b88d3

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

lib/private/App/AppStore/Fetcher/Fetcher.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
abstract class Fetcher {
4545
public const INVALIDATE_AFTER_SECONDS = 3600;
4646
public const RETRY_AFTER_FAILURE_SECONDS = 300;
47+
public const APP_STORE_URL = 'https://apps.nextcloud.com/api/v1';
4748

4849
/** @var IAppData */
4950
protected $appData;
@@ -109,7 +110,7 @@ protected function fetch($ETag, $content) {
109110
];
110111
}
111112

112-
if ($this->config->getSystemValueString('appstoreurl', 'https://apps.nextcloud.com/api/v1') === 'https://apps.nextcloud.com/api/v1') {
113+
if ($this->config->getSystemValueString('appstoreurl', self::APP_STORE_URL) === self::APP_STORE_URL) {
113114
// If we have a valid subscription key, send it to the appstore
114115
$subscriptionKey = $this->config->getAppValue('support', 'subscription_key');
115116
if ($this->registry->delegateHasValidSubscription() && $subscriptionKey) {
@@ -153,8 +154,9 @@ protected function fetch($ETag, $content) {
153154
public function get($allowUnstable = false) {
154155
$appstoreenabled = $this->config->getSystemValueBool('appstoreenabled', true);
155156
$internetavailable = $this->config->getSystemValueBool('has_internet_connection', true);
157+
$isDefaultAppStore = $this->config->getSystemValueString('appstoreurl', self::APP_STORE_URL) === self::APP_STORE_URL;
156158

157-
if (!$appstoreenabled || !$internetavailable) {
159+
if (!$appstoreenabled || (!$internetavailable && $isDefaultAppStore)) {
158160
return [];
159161
}
160162

tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public function testNoInternet() {
6464
}
6565
return $default;
6666
});
67+
$this->config
68+
->method('getSystemValueString')
69+
->willReturnCallback(function ($var, $default) {
70+
return $default;
71+
});
6772
$this->appData
6873
->expects($this->never())
6974
->method('getFolder');

tests/lib/App/AppStore/Fetcher/FetcherBase.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,13 @@ protected function setUp(): void {
7676

7777
public function testGetWithAlreadyExistingFileAndUpToDateTimestampAndVersion() {
7878
$this->config
79-
->expects($this->exactly(1))
8079
->method('getSystemValueString')
81-
->with($this->equalTo('version'), $this->anything())
82-
->willReturn('11.0.0.2');
80+
->willReturnCallback(function ($var, $default) {
81+
if ($var === 'version') {
82+
return '11.0.0.2';
83+
}
84+
return $default;
85+
});
8386
$this->config->method('getSystemValueBool')
8487
->willReturnArgument(1);
8588

0 commit comments

Comments
 (0)