summaryrefslogtreecommitdiffstats
path: root/lib/private/Files/ObjectStore/Swift.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Files/ObjectStore/Swift.php')
-rw-r--r--lib/private/Files/ObjectStore/Swift.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/private/Files/ObjectStore/Swift.php b/lib/private/Files/ObjectStore/Swift.php
index 70bc4ed8438..a3cba488f5f 100644
--- a/lib/private/Files/ObjectStore/Swift.php
+++ b/lib/private/Files/ObjectStore/Swift.php
@@ -26,6 +26,7 @@
namespace OC\Files\ObjectStore;
use Guzzle\Http\Exception\ClientErrorResponseException;
+use Guzzle\Http\Exception\CurlException;
use Icewind\Streams\RetryWrapper;
use OCP\Files\ObjectStore\IObjectStore;
use OCP\Files\StorageAuthException;
@@ -87,6 +88,9 @@ class Swift implements IObjectStore {
$this->params = $params;
}
+ /**
+ * @suppress PhanNonClassMethodCall
+ */
protected function init() {
if ($this->container) {
return;
@@ -117,6 +121,10 @@ class Swift implements IObjectStore {
/** @var Catalog $catalog */
$catalog = $this->client->getCatalog();
+ if (count($catalog->getItems()) === 0) {
+ throw new StorageAuthException('Keystone did not provide a valid catalog, verify the credentials');
+ }
+
if (isset($this->params['serviceName'])) {
$serviceName = $this->params['serviceName'];
} else {
@@ -153,6 +161,13 @@ class Swift implements IObjectStore {
} else {
throw $ex;
}
+ } catch (CurlException $e) {
+ if ($e->getErrorNo() === 7) {
+ $host = $e->getCurlHandle()->getUrl()->getHost() . ':' . $e->getCurlHandle()->getUrl()->getPort();
+ \OC::$server->getLogger()->error("Can't connect to object storage server at $host");
+ throw new StorageNotAvailableException("Can't connect to object storage server at $host", StorageNotAvailableException::STATUS_ERROR, $e);
+ }
+ throw $e;
}
}
@@ -176,7 +191,7 @@ class Swift implements IObjectStore {
$itemClass = new \stdClass();
$itemClass->name = $item['name'];
$itemClass->endpoints = array_map(function (array $endpoint) {
- return (object) $endpoint;
+ return (object)$endpoint;
}, $item['endpoints']);
$itemClass->type = $item['type'];