Skip to content

Commit 4d10c0a

Browse files
authored
Merge pull request #55439 from nextcloud/backport/55420/stable31
[stable31] fix(appstore): Make appstore timeout configurable
2 parents 79dd3fe + f23bcc5 commit 4d10c0a

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected function fetch($ETag, $content) {
6666
}
6767

6868
$options = [
69-
'timeout' => 60,
69+
'timeout' => (int)$this->config->getAppValue('settings', 'appstore-timeout', '120')
7070
];
7171

7272
if ($ETag !== '') {

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,7 +2132,7 @@ public function testGetAppsAllowlist(): void {
21322132
->expects($this->once())
21332133
->method('get')
21342134
->with('https://apps.nextcloud.com/api/v1/apps.json', [
2135-
'timeout' => 60,
2135+
'timeout' => 120,
21362136
'headers' => [
21372137
'X-NC-Subscription-Key' => 'subscription-key',
21382138
],
@@ -2190,6 +2190,12 @@ public function testGetAppsAllowlistCustomAppstore(): void {
21902190
->method('getSystemValueBool')
21912191
->willReturnArgument(1);
21922192

2193+
$this->config->method('getAppValue')
2194+
->willReturnMap([
2195+
['settings', 'appstore-fetcher-lastFailure', '0', '0'],
2196+
['settings', 'appstore-timeout', '120', '120'],
2197+
]);
2198+
21932199
$file = $this->createMock(ISimpleFile::class);
21942200
$folder = $this->createMock(ISimpleFolder::class);
21952201
$folder
@@ -2217,7 +2223,7 @@ public function testGetAppsAllowlistCustomAppstore(): void {
22172223
->expects($this->once())
22182224
->method('get')
22192225
->with('https://custom.appsstore.endpoint/api/v1/apps.json', [
2220-
'timeout' => 60,
2226+
'timeout' => 120,
22212227
])
22222228
->willReturn($response);
22232229
$response

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,12 @@ public function testGetMatchingETag(): void {
442442
$this->config->method('getSystemValueBool')
443443
->willReturnArgument(1);
444444

445+
$this->config->method('getAppValue')
446+
->willReturnMap([
447+
['settings', 'appstore-fetcher-lastFailure', '0', '0'],
448+
['settings', 'appstore-timeout', '120', '120'],
449+
]);
450+
445451
$folder = $this->createMock(ISimpleFolder::class);
446452
$file = $this->createMock(ISimpleFile::class);
447453
$this->appData
@@ -487,7 +493,7 @@ public function testGetMatchingETag(): void {
487493
->with(
488494
$this->equalTo($this->endpoint),
489495
$this->equalTo([
490-
'timeout' => 60,
496+
'timeout' => 120,
491497
'headers' => [
492498
'If-None-Match' => '"myETag"'
493499
]
@@ -521,6 +527,12 @@ public function testGetNoMatchingETag(): void {
521527
$this->config->method('getSystemValueBool')
522528
->willReturnArgument(1);
523529

530+
$this->config->method('getAppValue')
531+
->willReturnMap([
532+
['settings', 'appstore-fetcher-lastFailure', '0', '0'],
533+
['settings', 'appstore-timeout', '120', '120'],
534+
]);
535+
524536
$folder = $this->createMock(ISimpleFolder::class);
525537
$file = $this->createMock(ISimpleFile::class);
526538
$this->appData
@@ -564,7 +576,7 @@ public function testGetNoMatchingETag(): void {
564576
->with(
565577
$this->equalTo($this->endpoint),
566578
$this->equalTo([
567-
'timeout' => 60,
579+
'timeout' => 120,
568580
'headers' => [
569581
'If-None-Match' => '"myETag"',
570582
]
@@ -606,6 +618,12 @@ public function testFetchAfterUpgradeNoETag(): void {
606618
$this->config->method('getSystemValueBool')
607619
->willReturnArgument(1);
608620

621+
$this->config->method('getAppValue')
622+
->willReturnMap([
623+
['settings', 'appstore-fetcher-lastFailure', '0', '0'],
624+
['settings', 'appstore-timeout', '120', '120'],
625+
]);
626+
609627
$folder = $this->createMock(ISimpleFolder::class);
610628
$file = $this->createMock(ISimpleFile::class);
611629
$this->appData
@@ -642,7 +660,7 @@ public function testFetchAfterUpgradeNoETag(): void {
642660
->with(
643661
$this->equalTo($this->endpoint),
644662
$this->equalTo([
645-
'timeout' => 60,
663+
'timeout' => 120,
646664
])
647665
)
648666
->willReturn($response);

0 commit comments

Comments
 (0)