Skip to content

Commit e13fb46

Browse files
committed
fix: Fetch custom app store url without internet connection
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent 1d100bd commit e13fb46

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

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;
@@ -96,7 +97,7 @@ protected function fetch($ETag, $content) {
9697
];
9798
}
9899

99-
if ($this->config->getSystemValueString('appstoreurl', 'https://apps.nextcloud.com/api/v1') === 'https://apps.nextcloud.com/api/v1') {
100+
if ($this->config->getSystemValueString('appstoreurl', self::APP_STORE_URL) === self::APP_STORE_URL) {
100101
// If we have a valid subscription key, send it to the appstore
101102
$subscriptionKey = $this->config->getAppValue('support', 'subscription_key');
102103
if ($this->registry->delegateHasValidSubscription() && $subscriptionKey) {
@@ -140,8 +141,9 @@ protected function fetch($ETag, $content) {
140141
public function get($allowUnstable = false) {
141142
$appstoreenabled = $this->config->getSystemValueBool('appstoreenabled', true);
142143
$internetavailable = $this->config->getSystemValueBool('has_internet_connection', true);
144+
$isDefaultAppStore = $this->config->getSystemValueString('appstoreurl', self::APP_STORE_URL) === self::APP_STORE_URL;
143145

144-
if (!$appstoreenabled || !$internetavailable) {
146+
if (!$appstoreenabled || (!$internetavailable && $isDefaultAppStore)) {
145147
return [];
146148
}
147149

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)