summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-05-11 17:46:41 -0500
committerMorris Jobke <hey@morrisjobke.de>2017-05-11 17:46:41 -0500
commitc90d832ce4ab076a7d01e9d223b54a5e5ce4e7d4 (patch)
tree4bcd2b0a02c2ec2c91fde8542ab7c5b371aac83d
parentd83f1d96d4541e8e5a686be94b9c03ebb31f5f76 (diff)
downloadnextcloud-server-c90d832ce4ab076a7d01e9d223b54a5e5ce4e7d4.tar.gz
nextcloud-server-c90d832ce4ab076a7d01e9d223b54a5e5ce4e7d4.zip
Log connectiong problems while fetching data from appstore
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
-rw-r--r--lib/private/App/AppStore/Fetcher/AppFetcher.php10
-rw-r--r--lib/private/App/AppStore/Fetcher/CategoryFetcher.php8
-rw-r--r--lib/private/App/AppStore/Fetcher/Fetcher.php12
3 files changed, 24 insertions, 6 deletions
diff --git a/lib/private/App/AppStore/Fetcher/AppFetcher.php b/lib/private/App/AppStore/Fetcher/AppFetcher.php
index 2e181d754f1..63f63aaf695 100644
--- a/lib/private/App/AppStore/Fetcher/AppFetcher.php
+++ b/lib/private/App/AppStore/Fetcher/AppFetcher.php
@@ -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';
diff --git a/lib/private/App/AppStore/Fetcher/CategoryFetcher.php b/lib/private/App/AppStore/Fetcher/CategoryFetcher.php
index 4c786652833..8c3c963462c 100644
--- a/lib/private/App/AppStore/Fetcher/CategoryFetcher.php
+++ b/lib/private/App/AppStore/Fetcher/CategoryFetcher.php
@@ -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';
diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php
index ccf5162ed82..02c55ac9d91 100644
--- a/lib/private/App/AppStore/Fetcher/Fetcher.php
+++ b/lib/private/App/AppStore/Fetcher/Fetcher.php
@@ -22,12 +22,14 @@
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 [];
}