From f23bcc5580e0d808963dd13a511a6de20c81df00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Tue, 30 Sep 2025 11:20:26 +0200 Subject: [PATCH] fix(appstore): Make appstore timeout configurable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- lib/private/App/AppStore/Fetcher/Fetcher.php | 2 +- .../App/AppStore/Fetcher/AppFetcherTest.php | 10 ++++++-- .../lib/App/AppStore/Fetcher/FetcherBase.php | 24 ++++++++++++++++--- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php index f998c9e202369..d287a92b3c4f2 100644 --- a/lib/private/App/AppStore/Fetcher/Fetcher.php +++ b/lib/private/App/AppStore/Fetcher/Fetcher.php @@ -66,7 +66,7 @@ protected function fetch($ETag, $content) { } $options = [ - 'timeout' => 60, + 'timeout' => (int)$this->config->getAppValue('settings', 'appstore-timeout', '120') ]; if ($ETag !== '') { diff --git a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php index 61fe24be1a94d..774487458a09d 100644 --- a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php +++ b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php @@ -2132,7 +2132,7 @@ public function testGetAppsAllowlist(): void { ->expects($this->once()) ->method('get') ->with('https://apps.nextcloud.com/api/v1/apps.json', [ - 'timeout' => 60, + 'timeout' => 120, 'headers' => [ 'X-NC-Subscription-Key' => 'subscription-key', ], @@ -2190,6 +2190,12 @@ public function testGetAppsAllowlistCustomAppstore(): void { ->method('getSystemValueBool') ->willReturnArgument(1); + $this->config->method('getAppValue') + ->willReturnMap([ + ['settings', 'appstore-fetcher-lastFailure', '0', '0'], + ['settings', 'appstore-timeout', '120', '120'], + ]); + $file = $this->createMock(ISimpleFile::class); $folder = $this->createMock(ISimpleFolder::class); $folder @@ -2217,7 +2223,7 @@ public function testGetAppsAllowlistCustomAppstore(): void { ->expects($this->once()) ->method('get') ->with('https://custom.appsstore.endpoint/api/v1/apps.json', [ - 'timeout' => 60, + 'timeout' => 120, ]) ->willReturn($response); $response diff --git a/tests/lib/App/AppStore/Fetcher/FetcherBase.php b/tests/lib/App/AppStore/Fetcher/FetcherBase.php index 95129b3114dbf..4f421a64a3024 100644 --- a/tests/lib/App/AppStore/Fetcher/FetcherBase.php +++ b/tests/lib/App/AppStore/Fetcher/FetcherBase.php @@ -442,6 +442,12 @@ public function testGetMatchingETag(): void { $this->config->method('getSystemValueBool') ->willReturnArgument(1); + $this->config->method('getAppValue') + ->willReturnMap([ + ['settings', 'appstore-fetcher-lastFailure', '0', '0'], + ['settings', 'appstore-timeout', '120', '120'], + ]); + $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); $this->appData @@ -487,7 +493,7 @@ public function testGetMatchingETag(): void { ->with( $this->equalTo($this->endpoint), $this->equalTo([ - 'timeout' => 60, + 'timeout' => 120, 'headers' => [ 'If-None-Match' => '"myETag"' ] @@ -521,6 +527,12 @@ public function testGetNoMatchingETag(): void { $this->config->method('getSystemValueBool') ->willReturnArgument(1); + $this->config->method('getAppValue') + ->willReturnMap([ + ['settings', 'appstore-fetcher-lastFailure', '0', '0'], + ['settings', 'appstore-timeout', '120', '120'], + ]); + $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); $this->appData @@ -564,7 +576,7 @@ public function testGetNoMatchingETag(): void { ->with( $this->equalTo($this->endpoint), $this->equalTo([ - 'timeout' => 60, + 'timeout' => 120, 'headers' => [ 'If-None-Match' => '"myETag"', ] @@ -606,6 +618,12 @@ public function testFetchAfterUpgradeNoETag(): void { $this->config->method('getSystemValueBool') ->willReturnArgument(1); + $this->config->method('getAppValue') + ->willReturnMap([ + ['settings', 'appstore-fetcher-lastFailure', '0', '0'], + ['settings', 'appstore-timeout', '120', '120'], + ]); + $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); $this->appData @@ -642,7 +660,7 @@ public function testFetchAfterUpgradeNoETag(): void { ->with( $this->equalTo($this->endpoint), $this->equalTo([ - 'timeout' => 60, + 'timeout' => 120, ]) ) ->willReturn($response);