diff options
Diffstat (limited to 'lib/private/util.php')
-rwxr-xr-x | lib/private/util.php | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/lib/private/util.php b/lib/private/util.php index dfdddd0e3ab..5e019bf90b6 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -12,6 +12,39 @@ class OC_Util { private static $rootMounted=false; private static $fsSetup=false; + private static function initLocalStorageRootFS() { + // mount local file backend as root + $configDataDirectory = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ); + //first set up the local "root" storage + \OC\Files\Filesystem::initMounts(); + if(!self::$rootMounted) { + \OC\Files\Filesystem::mount('\OC\Files\Storage\Local', array('datadir'=>$configDataDirectory), '/'); + self::$rootMounted = true; + } + } + + /** + * mounting an object storage as the root fs will in essence remove the + * necessity of a data folder being present. + * TODO make home storage aware of this and use the object storage instead of local disk access + * @param array $config containing 'class' and optional 'arguments' + */ + private static function initObjectStorageRootFS($config) { + // check misconfiguration + if (empty($config['class'])) { + //FIXME log error? + } + if (!isset($config['arguments'])) { + $config['arguments'] = array(); + } + // mount object storage as root + \OC\Files\Filesystem::initMounts(); + if(!self::$rootMounted) { + \OC\Files\Filesystem::mount($config['class'], $config['arguments'], '/'); + self::$rootMounted = true; + } + } + /** * Can be set up * @param string $user @@ -39,12 +72,12 @@ class OC_Util { self::$fsSetup=true; } - $configDataDirectory = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ); - //first set up the local "root" storage - \OC\Files\Filesystem::initMounts(); - if(!self::$rootMounted) { - \OC\Files\Filesystem::mount('\OC\Files\Storage\Local', array('datadir'=>$configDataDirectory), '/'); - self::$rootMounted = true; + //check if we are using an object storage + $object_storage = OC_Config::getValue( 'object_storage' ); + if ( isset( $object_storage ) ) { + self::initObjectStorageRootFS($object_storage); + } else { + self::initLocalStorageRootFS(); } if ($user != '' && !OCP\User::userExists($user)) { @@ -60,7 +93,9 @@ class OC_Util { /** * @var \OC\Files\Storage\Storage $storage */ - if ($storage->instanceOfStorage('\OC\Files\Storage\Home')) { + if ($storage->instanceOfStorage('\OC\Files\Storage\Home') + || $storage->instanceOfStorage('\OCA\ObjectStore\AbstractObjectStore') // FIXME introduce interface \OC\Files\Storage\HomeStorage? or add method? + ) { $user = $storage->getUser()->getUID(); $quota = OC_Util::getUserQuota($user); if ($quota !== \OC\Files\SPACE_UNLIMITED) { |