diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-03-05 17:22:48 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-03-11 15:06:48 +0100 |
commit | 7adda887865d43ea66e4854826cbb64f942af42c (patch) | |
tree | 3bae4cebc69d414dee3a8f4c1c025ef1e25e9bd3 | |
parent | 4f0f175f8b1e8719e4b5858322be3d2e30280add (diff) | |
download | nextcloud-server-7adda887865d43ea66e4854826cbb64f942af42c.tar.gz nextcloud-server-7adda887865d43ea66e4854826cbb64f942af42c.zip |
Copy mount options to the storage
-rw-r--r-- | lib/private/files/mount/mountpoint.php | 2 | ||||
-rw-r--r-- | lib/private/files/storage/common.php | 18 | ||||
-rw-r--r-- | lib/private/util.php | 8 | ||||
-rw-r--r-- | tests/lib/files/view.php | 10 |
4 files changed, 37 insertions, 1 deletions
diff --git a/lib/private/files/mount/mountpoint.php b/lib/private/files/mount/mountpoint.php index 02bd8eaa70b..a187f4db109 100644 --- a/lib/private/files/mount/mountpoint.php +++ b/lib/private/files/mount/mountpoint.php @@ -195,7 +195,7 @@ class MountPoint implements IMountPoint { $storage = $this->getStorage(); // storage can be null if it couldn't be initialized if ($storage != null) { - $this->storage = $wrapper($this->mountPoint, $storage); + $this->storage = $wrapper($this->mountPoint, $storage, $this); } } diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index 8549d5a1fad..db66feb4609 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -34,6 +34,8 @@ abstract class Common implements \OC\Files\Storage\Storage { protected $watcher; protected $storageCache; + protected $mountOptions = []; + /** * @var string[] */ @@ -512,4 +514,20 @@ abstract class Common implements \OC\Files\Storage\Storage { throw new InvalidCharacterInPathException(); } } + + /** + * @param array $options + */ + public function setMountOptions(array $options) { + $this->mountOptions = $options; + } + + /** + * @param string $name + * @param mixed $default + * @return mixed + */ + public function getMountOption($name, $default = null) { + return isset($this->mountOptions[$name]) ? $this->mountOptions[$name] : $default; + } } diff --git a/lib/private/util.php b/lib/private/util.php index 72802409da9..cf76ff5c08e 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -98,6 +98,14 @@ class OC_Util { return false; } + \OC\Files\Filesystem::addStorageWrapper('mount_options', function($mountPoint, \OCP\Files\Storage $storage, \OCP\Files\Mount\IMountPoint $mount) { + if($storage->instanceOfStorage('\OC\Files\Storage\Common')) { + /** @var \OC\Files\Storage\Common $storage */ + $storage->setMountOptions($mount->getOptions()); + } + return $storage; + }); + //if we aren't logged in, there is no use to set up the filesystem if ($user != "") { \OC\Files\Filesystem::addStorageWrapper('oc_quota', function ($mountPoint, $storage) { diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php index db39df7d16b..4ac014a92b5 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -8,6 +8,8 @@ namespace Test\Files; use OC\Files\Cache\Watcher; +use OC\Files\Filesystem; +use OC\Files\Mount\MountPoint; use OC\Files\Storage\Temporary; class TemporaryNoTouch extends \OC\Files\Storage\Temporary { @@ -975,4 +977,12 @@ class View extends \Test\TestCase { $view = new \OC\Files\View(''); $this->assertTrue($view->rename('/test/foo.txt', '/test/foo/bar.txt')); } + + public function testSetMountOptionsInStorage() { + $mount = new MountPoint('\OC\Files\Storage\Temporary', '/asd/', [[]], Filesystem::getLoader(), ['foo' => 'bar']); + Filesystem::getMountManager()->addMount($mount); + /** @var \OC\Files\Storage\Common $storage */ + $storage = $mount->getStorage(); + $this->assertEquals($storage->getMountOption('foo'), 'bar'); + } } |