[Pkg-owncloud-commits] [owncloud] 109/153: Add storage priority support
David Prévot
taffit at moszumanska.debian.org
Tue May 27 03:05:43 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 05642733a365cd150dd9ebb3b7cf7ec9c55ecab3
Author: Robin McCorkell <rmccorkell at karoshi.org.uk>
Date: Fri Mar 28 14:24:38 2014 +0000
Add storage priority support
Each storage backend has a default priority, assigned to any system mounts
created in ownCloud. mount.json can be manually modified to change these
priorities.
The priority order is as follows:
* Personal
* User
* Group
* Global
Within each mount type, the mount with the highest priority is active.
The storage backend defaults were chosen to be the following:
* Local - 150
* Remote storage - 100
* SMB / CIFS with OC login - 90
---
apps/files_external/appinfo/app.php | 12 +++++++++
apps/files_external/lib/config.php | 52 ++++++++++++++++++++++++++++++++++---
2 files changed, 60 insertions(+), 4 deletions(-)
diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php
index e8ed895..ca16478 100644
--- a/apps/files_external/appinfo/app.php
+++ b/apps/files_external/appinfo/app.php
@@ -32,11 +32,13 @@ OCP\Util::connectHook('OC_User', 'post_login', 'OC\Files\Storage\SMB_OC', 'login
OC_Mount_Config::registerBackend('\OC\Files\Storage\Local', array(
'backend' => (string)$l->t('Local'),
+ 'priority' => 150,
'configuration' => array(
'datadir' => (string)$l->t('Location'))));
OC_Mount_Config::registerBackend('\OC\Files\Storage\AmazonS3', array(
'backend' => (string)$l->t('Amazon S3'),
+ 'priority' => 100,
'configuration' => array(
'key' => (string)$l->t('Key'),
'secret' => '*'.$l->t('Secret'),
@@ -45,6 +47,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\AmazonS3', array(
OC_Mount_Config::registerBackend('\OC\Files\Storage\AmazonS3', array(
'backend' => (string)$l->t('Amazon S3 and compliant'),
+ 'priority' => 100,
'configuration' => array(
'key' => (string)$l->t('Access Key'),
'secret' => '*'.$l->t('Secret Key'),
@@ -58,6 +61,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\AmazonS3', array(
OC_Mount_Config::registerBackend('\OC\Files\Storage\Dropbox', array(
'backend' => 'Dropbox',
+ 'priority' => 100,
'configuration' => array(
'configured' => '#configured',
'app_key' => (string)$l->t('App key'),
@@ -69,6 +73,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\Dropbox', array(
OC_Mount_Config::registerBackend('\OC\Files\Storage\FTP', array(
'backend' => 'FTP',
+ 'priority' => 100,
'configuration' => array(
'host' => (string)$l->t('Host'),
'user' => (string)$l->t('Username'),
@@ -79,6 +84,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\FTP', array(
OC_Mount_Config::registerBackend('\OC\Files\Storage\Google', array(
'backend' => 'Google Drive',
+ 'priority' => 100,
'configuration' => array(
'configured' => '#configured',
'client_id' => (string)$l->t('Client ID'),
@@ -90,6 +96,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\Google', array(
OC_Mount_Config::registerBackend('\OC\Files\Storage\Swift', array(
'backend' => (string)$l->t('OpenStack Object Storage'),
+ 'priority' => 100,
'configuration' => array(
'user' => (string)$l->t('Username (required)'),
'bucket' => (string)$l->t('Bucket (required)'),
@@ -107,6 +114,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\Swift', array(
if (!OC_Util::runningOnWindows()) {
OC_Mount_Config::registerBackend('\OC\Files\Storage\SMB', array(
'backend' => 'SMB / CIFS',
+ 'priority' => 100,
'configuration' => array(
'host' => (string)$l->t('Host'),
'user' => (string)$l->t('Username'),
@@ -117,6 +125,7 @@ if (!OC_Util::runningOnWindows()) {
OC_Mount_Config::registerBackend('\OC\Files\Storage\SMB_OC', array(
'backend' => (string)$l->t('SMB / CIFS using OC login'),
+ 'priority' => 90,
'configuration' => array(
'host' => (string)$l->t('Host'),
'username_as_share' => '!'.$l->t('Username as share'),
@@ -127,6 +136,7 @@ if (!OC_Util::runningOnWindows()) {
OC_Mount_Config::registerBackend('\OC\Files\Storage\DAV', array(
'backend' => 'WebDAV',
+ 'priority' => 100,
'configuration' => array(
'host' => (string)$l->t('URL'),
'user' => (string)$l->t('Username'),
@@ -137,6 +147,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\DAV', array(
OC_Mount_Config::registerBackend('\OC\Files\Storage\OwnCloud', array(
'backend' => 'ownCloud',
+ 'priority' => 100,
'configuration' => array(
'host' => (string)$l->t('URL'),
'user' => (string)$l->t('Username'),
@@ -147,6 +158,7 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\OwnCloud', array(
OC_Mount_Config::registerBackend('\OC\Files\Storage\SFTP', array(
'backend' => 'SFTP',
+ 'priority' => 100,
'configuration' => array(
'host' => (string)$l->t('Host'),
'user' => (string)$l->t('Username'),
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 7a65123..e23a72b 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -126,6 +126,8 @@ class OC_Mount_Config {
$datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data");
$mount_file = \OC_Config::getValue("mount_file", $datadir . "/mount.json");
+ $backends = self::getBackends();
+
//move config file to it's new position
if (is_file(\OC::$SERVERROOT . '/config/mount.json')) {
rename(\OC::$SERVERROOT . '/config/mount.json', $mount_file);
@@ -136,7 +138,15 @@ class OC_Mount_Config {
if (isset($mountConfig[self::MOUNT_TYPE_GLOBAL])) {
foreach ($mountConfig[self::MOUNT_TYPE_GLOBAL] as $mountPoint => $options) {
$options['options'] = self::decryptPasswords($options['options']);
- $mountPoints[$mountPoint] = $options;
+ if (!isset($options['priority'])) {
+ $options['priority'] = $backends[$options['class']]['priority'];
+ }
+
+ if ( (!isset($mountPoints[$mountPoint]))
+ || ($options['priority'] >= $mountPoints[$mountPoint]['priority']) ) {
+ $options['priority_type'] = 'global';
+ $mountPoints[$mountPoint] = $options;
+ }
}
}
if (isset($mountConfig[self::MOUNT_TYPE_GROUP])) {
@@ -148,7 +158,16 @@ class OC_Mount_Config {
$option = self::setUserVars($user, $option);
}
$options['options'] = self::decryptPasswords($options['options']);
- $mountPoints[$mountPoint] = $options;
+ if (!isset($options['priority'])) {
+ $options['priority'] = $backends[$options['class']]['priority'];
+ }
+
+ if ( (!isset($mountPoints[$mountPoint]))
+ || ($options['priority'] >= $mountPoints[$mountPoint]['priority'])
+ || ($mountPoints[$mountPoint]['priority_type'] != 'group') ) {
+ $options['priority_type'] = 'group';
+ $mountPoints[$mountPoint] = $options;
+ }
}
}
}
@@ -162,7 +181,16 @@ class OC_Mount_Config {
$option = self::setUserVars($user, $option);
}
$options['options'] = self::decryptPasswords($options['options']);
- $mountPoints[$mountPoint] = $options;
+ if (!isset($options['priority'])) {
+ $options['priority'] = $backends[$options['class']]['priority'];
+ }
+
+ if ( (!isset($mountPoints[$mountPoint]))
+ || ($options['priority'] >= $mountPoints[$mountPoint]['priority'])
+ || ($mountPoints[$mountPoint]['priority_type'] != 'user') ) {
+ $options['priority_type'] = 'user';
+ $mountPoints[$mountPoint] = $options;
+ }
}
}
}
@@ -173,7 +201,12 @@ class OC_Mount_Config {
if (isset($mountConfig[self::MOUNT_TYPE_USER][$user])) {
foreach ($mountConfig[self::MOUNT_TYPE_USER][$user] as $mountPoint => $options) {
$options['options'] = self::decryptPasswords($options['options']);
- $mountPoints[$mountPoint] = $options;
+
+ if ( (!isset($mountPoints[$mountPoint]))
+ || ($mountPoints[$mountPoint]['priority_type'] != 'personal') ) {
+ $options['priority_type'] = 'personal';
+ $mountPoints[$mountPoint] = $options;
+ }
}
}
@@ -244,6 +277,9 @@ class OC_Mount_Config {
$mount['class'] = '\OC\Files\Storage\\'.substr($mount['class'], 15);
}
$mount['options'] = self::decryptPasswords($mount['options']);
+ if (!isset($mount['priority'])) {
+ $mount['priority'] = $backends[$mount['class']]['priority'];
+ }
// Remove '/$user/files/' from mount point
$mountPoint = substr($mountPoint, 13);
@@ -251,6 +287,7 @@ class OC_Mount_Config {
'class' => $mount['class'],
'mountpoint' => $mountPoint,
'backend' => $backends[$mount['class']]['backend'],
+ 'priority' => $mount['priority'],
'options' => $mount['options'],
'applicable' => array('groups' => array($group), 'users' => array()),
'status' => self::getBackendStatus($mount['class'], $mount['options'], false)
@@ -275,12 +312,16 @@ class OC_Mount_Config {
$mount['class'] = '\OC\Files\Storage\\'.substr($mount['class'], 15);
}
$mount['options'] = self::decryptPasswords($mount['options']);
+ if (!isset($mount['priority'])) {
+ $mount['priority'] = $backends[$mount['class']]['priority'];
+ }
// Remove '/$user/files/' from mount point
$mountPoint = substr($mountPoint, 13);
$config = array(
'class' => $mount['class'],
'mountpoint' => $mountPoint,
'backend' => $backends[$mount['class']]['backend'],
+ 'priority' => $mount['priority'],
'options' => $mount['options'],
'applicable' => array('groups' => array(), 'users' => array($user)),
'status' => self::getBackendStatus($mount['class'], $mount['options'], false)
@@ -400,6 +441,9 @@ class OC_Mount_Config {
'options' => self::encryptPasswords($classOptions))
)
);
+ if (! $isPersonal) {
+ $mount[$applicable][$mountPoint]['priority'] = $backends[$class]['priority'];
+ }
$mountPoints = self::readData($isPersonal ? OCP\User::getUser() : NULL);
$mountPoints = self::mergeMountPoints($mountPoints, $mount, $mountType);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list