]> source.dussan.org Git - nextcloud-server.git/commitdiff
Load mount specific options from the mount config
authorRobin Appelman <icewind@owncloud.com>
Tue, 16 Dec 2014 12:33:58 +0000 (13:33 +0100)
committerRobin Appelman <icewind@owncloud.com>
Wed, 17 Dec 2014 13:03:50 +0000 (14:03 +0100)
apps/files_external/lib/config/configadapter.php
lib/private/files/mount/mountpoint.php
lib/public/files/mount/imountpoint.php

index 6294e27a774a6722d92b5af029f237b9497084fa..de484a446984e95245877a04b4954bf227d9a4a8 100644 (file)
@@ -33,10 +33,11 @@ class ConfigAdapter implements IMountProvider {
                                $objectClass = $options['options']['objectstore']['class'];
                                $options['options']['objectstore'] = new $objectClass($options['options']['objectstore']);
                        }
+                       $mountOptions = isset($options['mountOptions']) ? $options['mountOptions'] : [];
                        if (isset($options['personal']) && $options['personal']) {
-                               $mounts[] = new PersonalMount($options['class'], $mountPoint, $options['options'], $loader);
+                               $mounts[] = new PersonalMount($options['class'], $mountPoint, $options['options'], $loader, $mountOptions);
                        } else {
-                               $mounts[] = new MountPoint($options['class'], $mountPoint, $options['options'], $loader);
+                               $mounts[] = new MountPoint($options['class'], $mountPoint, $options['options'], $loader, $mountOptions);
                        }
                }
                return $mounts;
index b2c50f9d88128272fe477b60a44cc4a8a5adc662..77a51a17020390511af6c26b38dc8c596afc2704 100644 (file)
@@ -20,9 +20,22 @@ class MountPoint implements IMountPoint {
        protected $storage = null;
        protected $class;
        protected $storageId;
+
+       /**
+        * Configuration options for the storage backend
+        *
+        * @var array
+        */
        protected $arguments = array();
        protected $mountPoint;
 
+       /**
+        * Mount specific options
+        *
+        * @var array
+        */
+       protected $mountOptions = array();
+
        /**
         * @var \OC\Files\Storage\StorageFactory $loader
         */
@@ -31,10 +44,11 @@ class MountPoint implements IMountPoint {
        /**
         * @param string|\OC\Files\Storage\Storage $storage
         * @param string $mountpoint
-        * @param array $arguments (optional)\
+        * @param array $arguments (optional) configuration for the storage backend
         * @param \OCP\Files\Storage\IStorageFactory $loader
+        * @param array $mountOptions mount specific options
         */
-       public function __construct($storage, $mountpoint, $arguments = null, $loader = null) {
+       public function __construct($storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null) {
                if (is_null($arguments)) {
                        $arguments = array();
                }
@@ -44,6 +58,10 @@ class MountPoint implements IMountPoint {
                        $this->loader = $loader;
                }
 
+               if (!is_null($mountOptions)) {
+                       $this->mountOptions = $mountOptions;
+               }
+
                $mountpoint = $this->formatPath($mountpoint);
                if ($storage instanceof Storage) {
                        $this->class = get_class($storage);
@@ -161,4 +179,15 @@ class MountPoint implements IMountPoint {
        public function wrapStorage($wrapper) {
                $this->storage = $wrapper($this->mountPoint, $this->getStorage());
        }
+
+       /**
+        * Get a mount option
+        *
+        * @param string $name Name of the mount option to get
+        * @param mixed $default Default value for the mount option
+        * @return mixed
+        */
+       public function getOption($name, $default) {
+               return isset($this->mountOptions[$name]) ? $this->mountOptions[$name] : $default;
+       }
 }
index dac634bae4cbb64842dfa80089fe18bd746b234d..af7819ae16080be4e1f21bf093442be7057fde9e 100644 (file)
@@ -55,4 +55,13 @@ interface IMountPoint {
         * @param callable $wrapper
         */
        public function wrapStorage($wrapper);
+
+       /**
+        * Get a mount option
+        *
+        * @param string $name Name of the mount option to get
+        * @param mixed $default Default value for the mount option
+        * @return mixed
+        */
+       public function getOption($name, $default);
 }