use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
+use OCP\ILogger;
class AppFetcher extends Fetcher {
/**
* @param Factory $appDataFactory
* @param IClientService $clientService
* @param ITimeFactory $timeFactory
- * @param IConfig $config;
+ * @param IConfig $config
+ * @param ILogger $logger
*/
public function __construct(Factory $appDataFactory,
IClientService $clientService,
ITimeFactory $timeFactory,
- IConfig $config) {
+ IConfig $config,
+ ILogger $logger) {
parent::__construct(
$appDataFactory,
$clientService,
$timeFactory,
- $config
+ $config,
+ $logger
);
$this->fileName = 'apps.json';
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
+use OCP\ILogger;
class CategoryFetcher extends Fetcher {
/**
* @param IClientService $clientService
* @param ITimeFactory $timeFactory
* @param IConfig $config
+ * @param ILogger $logger
*/
public function __construct(Factory $appDataFactory,
IClientService $clientService,
ITimeFactory $timeFactory,
- IConfig $config) {
+ IConfig $config,
+ ILogger $logger) {
parent::__construct(
$appDataFactory,
$clientService,
$timeFactory,
- $config
+ $config,
+ $logger
);
$this->fileName = 'categories.json';
$this->endpointUrl = 'https://apps.nextcloud.com/api/v1/categories.json';
namespace OC\App\AppStore\Fetcher;
use OC\Files\AppData\Factory;
+use GuzzleHttp\Exception\ConnectException;
use OCP\AppFramework\Http;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
+use OCP\ILogger;
abstract class Fetcher {
const INVALIDATE_AFTER_SECONDS = 300;
protected $timeFactory;
/** @var IConfig */
protected $config;
+ /** @var Ilogger */
+ protected $logger;
/** @var string */
protected $fileName;
/** @var string */
* @param IClientService $clientService
* @param ITimeFactory $timeFactory
* @param IConfig $config
+ * @param ILogger $logger
*/
public function __construct(Factory $appDataFactory,
IClientService $clientService,
ITimeFactory $timeFactory,
- IConfig $config) {
+ IConfig $config,
+ ILogger $logger) {
$this->appData = $appDataFactory->get('appstore');
$this->clientService = $clientService;
$this->timeFactory = $timeFactory;
$this->config = $config;
+ $this->logger = $logger;
}
/**
$responseJson = $this->fetch($ETag, $content);
$file->putContent(json_encode($responseJson));
return json_decode($file->getContent(), true)['data'];
+ } catch (ConnectException $e) {
+ $this->logger->logException($e, ['app' => 'appstoreFetcher']);
+ return [];
} catch (\Exception $e) {
return [];
}