]> source.dussan.org Git - nextcloud-server.git/commitdiff
Log connectiong problems while fetching data from appstore
authorMorris Jobke <hey@morrisjobke.de>
Thu, 11 May 2017 22:46:41 +0000 (17:46 -0500)
committerMorris Jobke <hey@morrisjobke.de>
Thu, 11 May 2017 22:46:41 +0000 (17:46 -0500)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
lib/private/App/AppStore/Fetcher/AppFetcher.php
lib/private/App/AppStore/Fetcher/CategoryFetcher.php
lib/private/App/AppStore/Fetcher/Fetcher.php

index 2e181d754f126d4886e77c45cd5e199dc8f1462b..63f63aaf695a90cf3abed3f60230515915296d96 100644 (file)
@@ -26,23 +26,27 @@ use OC\Files\AppData\Factory;
 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';
index 4c78665283386c2c617ce36b3b4b9f969d5e7298..8c3c963462ce9ea2403136f0d7cfa8a76971fc74 100644 (file)
@@ -25,6 +25,7 @@ use OC\Files\AppData\Factory;
 use OCP\AppFramework\Utility\ITimeFactory;
 use OCP\Http\Client\IClientService;
 use OCP\IConfig;
+use OCP\ILogger;
 
 class CategoryFetcher extends Fetcher {
        /**
@@ -32,16 +33,19 @@ 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';
index ccf5162ed82c4806fe1172caf76c1757f08ab075..02c55ac9d9198f136f330b239ade9e54d4a023a1 100644 (file)
 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;
@@ -40,6 +42,8 @@ abstract class Fetcher {
        protected $timeFactory;
        /** @var IConfig */
        protected $config;
+       /** @var Ilogger */
+       protected $logger;
        /** @var string */
        protected $fileName;
        /** @var string */
@@ -52,15 +56,18 @@ abstract class 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) {
                $this->appData = $appDataFactory->get('appstore');
                $this->clientService = $clientService;
                $this->timeFactory = $timeFactory;
                $this->config = $config;
+               $this->logger = $logger;
        }
 
        /**
@@ -153,6 +160,9 @@ abstract class Fetcher {
                        $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 [];
                }