Skip to content

Commit

Permalink
make object prefix configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
butonic authored and MorrisJobke committed Nov 14, 2016
1 parent cebb689 commit 4a93619
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
10 changes: 6 additions & 4 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -1005,16 +1005,18 @@
*
* One way to test is applying for a trystack account at http://trystack.org/
*/
'objectstore' => array(
'objectstore' => [
'class' => 'OC\\Files\\ObjectStore\\Swift',
'arguments' => array(
'arguments' => [
// trystack will user your facebook id as the user name
'username' => 'facebook100000123456789',
// in the trystack dashboard go to user -> settings -> API Password to
// generate a password
'password' => 'Secr3tPaSSWoRdt7',
// must already exist in the objectstore, name can be different
'container' => 'nextcloud',
// prefix to prepend to the fileid, default is 'oid:urn:'
'objectPrefix' => 'oid:urn:',
// create the container if it does not exist. default is false
'autocreate' => true,
// required, dev-/trystack defaults to 'RegionOne'
Expand All @@ -1028,8 +1030,8 @@
'serviceName' => 'swift',
// The Interface / url Type, optional
'urlType' => 'internal'
),
),
],
],


/**
Expand Down
7 changes: 6 additions & 1 deletion lib/private/Files/ObjectStore/ObjectStoreStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
*/
protected $user;

private $objectPrefix = 'urn:oid:';

public function __construct($params) {
if (isset($params['objectstore']) && $params['objectstore'] instanceof IObjectStore) {
$this->objectStore = $params['objectstore'];
Expand All @@ -59,6 +61,9 @@ public function __construct($params) {
} else {
$this->id = 'object::store:' . $this->objectStore->getStorageId();
}
if (isset($params['objectPrefix'])) {
$this->objectPrefix = $params['objectPrefix'];
}
//initialize cache with root directory in cache
if (!$this->is_dir('/')) {
$this->mkdir('/');
Expand Down Expand Up @@ -216,7 +221,7 @@ public function stat($path) {
*/
protected function getURN($fileId) {
if (is_numeric($fileId)) {
return 'urn:oid:' . $fileId;
return $this->objectPrefix . $fileId;
}
return null;
}
Expand Down
1 change: 1 addition & 0 deletions tests/objectstore/start-swift-ceph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ cat > $thisFolder/swift.config.php <<DELIM
'username' => '$user',
'password' => '$pass',
'container' => 'owncloud-autotest$EXECUTOR_NUMBER',
'objectPrefix' => 'autotest$EXECUTOR_NUMBER:oid:urn:',
'autocreate' => true,
'region' => '$region',
'url' => 'http://$host:$port/v2.0',
Expand Down

0 comments on commit 4a93619

Please sign in to comment.