summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-12-16 13:33:58 +0100
committerRobin Appelman <icewind@owncloud.com>2014-12-17 14:03:50 +0100
commit95a145f67f037d5b91ecebc33deaefbb4af96a79 (patch)
tree71214adb6ed3fb1a4185d4cd072ddaa7abaf97fd
parent532ba99f1ccc092dc5ddfbc15b70a027bca3e558 (diff)
downloadnextcloud-server-95a145f67f037d5b91ecebc33deaefbb4af96a79.tar.gz
nextcloud-server-95a145f67f037d5b91ecebc33deaefbb4af96a79.zip
Load mount specific options from the mount config
-rw-r--r--apps/files_external/lib/config/configadapter.php5
-rw-r--r--lib/private/files/mount/mountpoint.php33
-rw-r--r--lib/public/files/mount/imountpoint.php9
3 files changed, 43 insertions, 4 deletions
diff --git a/apps/files_external/lib/config/configadapter.php b/apps/files_external/lib/config/configadapter.php
index 6294e27a774..de484a44698 100644
--- a/apps/files_external/lib/config/configadapter.php
+++ b/apps/files_external/lib/config/configadapter.php
@@ -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;
diff --git a/lib/private/files/mount/mountpoint.php b/lib/private/files/mount/mountpoint.php
index b2c50f9d881..77a51a17020 100644
--- a/lib/private/files/mount/mountpoint.php
+++ b/lib/private/files/mount/mountpoint.php
@@ -20,10 +20,23 @@ 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
*/
private $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;
+ }
}
diff --git a/lib/public/files/mount/imountpoint.php b/lib/public/files/mount/imountpoint.php
index dac634bae4c..af7819ae160 100644
--- a/lib/public/files/mount/imountpoint.php
+++ b/lib/public/files/mount/imountpoint.php
@@ -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);
}