mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(appstore): address review comments on GenericFileException handling
- Attempt delete before logging the warning, so the warning only fires when we know recovery will succeed - Log an error (not silently return) when delete itself fails - Use catch (\Exception) without variable (PHP 8) - Replace willReturnArgument(1) with explicit willReturn(true) in test - Add blank lines between logical blocks in test for readability Signed-off-by: Anna Larch <anna@nextcloud.com> AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
52ca11addd
commit
b723c94246
2 changed files with 6 additions and 3 deletions
|
|
@ -165,12 +165,13 @@ abstract class Fetcher {
|
|||
// File does not already exist
|
||||
$file = $rootFolder->newFile($this->fileName);
|
||||
} catch (GenericFileException $e) {
|
||||
$this->logger->warning('Could not read appstore cache file, it will be refreshed', ['app' => 'appstoreFetcher', 'exception' => $e]);
|
||||
try {
|
||||
$file->delete();
|
||||
} catch (\Exception $deleteException) {
|
||||
} catch (\Exception) {
|
||||
$this->logger->error('Could not read appstore cache file', ['app' => 'appstoreFetcher', 'exception' => $e]);
|
||||
return [];
|
||||
}
|
||||
$this->logger->warning('Could not read appstore cache file, it will be refreshed', ['app' => 'appstoreFetcher', 'exception' => $e]);
|
||||
$file = $rootFolder->newFile($this->fileName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -697,7 +697,7 @@ abstract class FetcherBase extends TestCase {
|
|||
return $default;
|
||||
});
|
||||
$this->config->method('getSystemValueBool')
|
||||
->willReturnArgument(1);
|
||||
->willReturn(true);
|
||||
|
||||
$folder = $this->createMock(ISimpleFolder::class);
|
||||
$corruptedFile = $this->createMock(ISimpleFile::class);
|
||||
|
|
@ -724,6 +724,7 @@ abstract class FetcherBase extends TestCase {
|
|||
->method('newFile')
|
||||
->with($this->fileName)
|
||||
->willReturn($freshFile);
|
||||
|
||||
$client = $this->createMock(IClient::class);
|
||||
$this->clientService
|
||||
->expects($this->once())
|
||||
|
|
@ -742,6 +743,7 @@ abstract class FetcherBase extends TestCase {
|
|||
$response->method('getHeader')
|
||||
->with($this->equalTo('ETag'))
|
||||
->willReturn('"myETag"');
|
||||
|
||||
$fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1502,"ncversion":"11.0.0.2","ETag":"\"myETag\""}';
|
||||
$freshFile
|
||||
->expects($this->once())
|
||||
|
|
|
|||
Loading…
Reference in a new issue