Skip to content

Commit 36906ff

Browse files
authored
Merge pull request #891 from nextcloud/fix/exapp-fetcher-generic-file-exception
fix(fetcher): catch GenericFileException when reading the appstore cache file
2 parents 97af4a3 + b7c677c commit 36906ff

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

lib/Fetcher/AppAPIFetcher.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use OCA\AppAPI\AppInfo\Application;
1616
use OCP\AppFramework\Http;
1717
use OCP\AppFramework\Utility\ITimeFactory;
18+
use OCP\Files\GenericFileException;
1819
use OCP\Files\IAppData;
1920
use OCP\Files\NotFoundException;
2021
use OCP\Files\NotPermittedException;
@@ -148,6 +149,16 @@ public function get(bool $allowUnstable = false): array {
148149
} catch (NotFoundException $e) {
149150
// File does not already exists
150151
$file = $rootFolder->newFile($this->fileName);
152+
} catch (GenericFileException $e) {
153+
// File exists but is unreadable (I/O or OS-level permission failure); drop it and refresh
154+
try {
155+
$file->delete();
156+
} catch (Exception) {
157+
$this->logger->error('Could not read appstore cache file', ['app' => 'appstoreExAppFetcher', 'exception' => $e]);
158+
return [];
159+
}
160+
$this->logger->warning('Could not read appstore cache file, it will be refreshed', ['app' => 'appstoreExAppFetcher', 'exception' => $e]);
161+
$file = $rootFolder->newFile($this->fileName);
151162
}
152163

153164
// Refresh the file content

0 commit comments

Comments
 (0)