Merge pull request #8793 from nextcloud/swift-config

Swift uses `containter` not `bucket`
This commit is contained in:
Roeland Jago Douma 2018-03-15 08:34:58 +01:00 committed by GitHub
commit fde08a9619
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -1226,13 +1226,13 @@ $CONFIG = array(
'password' => 'swift', 'password' => 'swift',
'domain' => [ 'domain' => [
'name' => 'default', 'name' => 'default',
] ],
], ],
'tenantName' => 'service', 'tenantName' => 'service',
'serviceName' => 'swift', 'serviceName' => 'swift',
'region' => 'regionOne', 'region' => 'regionOne',
'url' => "http://yourswifthost:5000/v3", 'url' => "http://yourswifthost:5000/v3",
'bucket' => 'nextcloud' 'bucket' => 'nextcloud',
], ],
], ],

View File

@ -62,6 +62,10 @@ class Swift implements IObjectStore {
* @return string the container name where objects are stored * @return string the container name where objects are stored
*/ */
public function getStorageId() { public function getStorageId() {
if (isset($this->params['bucket'])) {
return $this->params['bucket'];
}
return $this->params['container']; return $this->params['container'];
} }

View File

@ -77,7 +77,7 @@ class SwiftFactory {
$this->params['container'] = $this->params['bucket']; $this->params['container'] = $this->params['bucket'];
} }
if (!isset($this->params['container'])) { if (!isset($this->params['container'])) {
$this->params['container'] = 'owncloud'; $this->params['container'] = 'nextcloud';
} }
if (!isset($this->params['autocreate'])) { if (!isset($this->params['autocreate'])) {
// should only be true for tests // should only be true for tests
@ -95,7 +95,7 @@ class SwiftFactory {
$this->params['tenantName'] = $this->params['tenant']; $this->params['tenantName'] = $this->params['tenant'];
} }
$cacheKey = $userName . '@' . $this->params['url'] . '/' . $this->params['bucket']; $cacheKey = $userName . '@' . $this->params['url'] . '/' . $this->params['container'];
$token = $this->getCachedToken($cacheKey); $token = $this->getCachedToken($cacheKey);
$hasToken = is_array($token) && (new \DateTimeImmutable($token['expires_at'])) > (new \DateTimeImmutable('now')); $hasToken = is_array($token) && (new \DateTimeImmutable($token['expires_at'])) > (new \DateTimeImmutable('now'));
if ($hasToken) { if ($hasToken) {