aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorRobin McCorkell <rmccorkell@karoshi.org.uk>2014-05-14 22:34:38 +0100
committerRobin McCorkell <rmccorkell@karoshi.org.uk>2014-05-21 22:18:22 +0100
commit0a8a3199158a7a52c071054df4b4d740c90db5ac (patch)
treeb21553e1bedaad63d28aa5645484301a9ac1324b /apps/files_external
parenteae45dca71a089aa72cc780ecee7a9d7dd9ab3a1 (diff)
downloadnextcloud-server-0a8a3199158a7a52c071054df4b4d740c90db5ac.tar.gz
nextcloud-server-0a8a3199158a7a52c071054df4b4d740c90db5ac.zip
Fix priority merging logic and add unit test
Diffstat (limited to 'apps/files_external')
-rwxr-xr-xapps/files_external/lib/config.php7
-rw-r--r--apps/files_external/tests/mountconfig.php48
2 files changed, 55 insertions, 0 deletions
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 788a136c387..d47a2b4547b 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -769,6 +769,13 @@ class OC_Mount_Config {
$mountPath = key($mountPoint[$applicable]);
if (isset($data[$mountType])) {
if (isset($data[$mountType][$applicable])) {
+ // Merge priorities
+ if (isset($data[$mountType][$applicable][$mountPath])
+ && isset($data[$mountType][$applicable][$mountPath]['priority'])
+ && !isset($mountPoint[$applicable][$mountPath]['priority'])) {
+ $mountPoint[$applicable][$mountPath]['priority']
+ = $data[$mountType][$applicable][$mountPath]['priority'];
+ }
$data[$mountType][$applicable]
= array_merge($data[$mountType][$applicable], $mountPoint[$applicable]);
} else {
diff --git a/apps/files_external/tests/mountconfig.php b/apps/files_external/tests/mountconfig.php
index 33cbd10d9e9..9b04e200e2b 100644
--- a/apps/files_external/tests/mountconfig.php
+++ b/apps/files_external/tests/mountconfig.php
@@ -752,4 +752,52 @@ class Test_Mount_Config extends \PHPUnit_Framework_TestCase {
$this->assertEquals(1, count($mountPoints));
$this->assertEquals($expected, $mountPoints['/'.self::TEST_USER1.'/files/ext']['options']['id']);
}
+
+ /**
+ * Test for persistence of priority when changing mount options
+ */
+ public function testPriorityPersistence() {
+ $class = '\OC\Files\Storage\SMB';
+ $priority = 123;
+ $mountConfig = array(
+ 'host' => 'somehost',
+ 'user' => 'someuser',
+ 'password' => 'somepassword',
+ 'root' => 'someroot'
+ );
+
+ $this->assertTrue(
+ OC_Mount_Config::addMountPoint(
+ '/ext',
+ $class,
+ $mountConfig,
+ OC_Mount_Config::MOUNT_TYPE_USER,
+ self::TEST_USER1,
+ false,
+ $priority
+ )
+ );
+
+ // Check for correct priority
+ $mountPoints = OC_Mount_Config::getAbsoluteMountPoints(self::TEST_USER1);
+ $this->assertEquals($priority,
+ $mountPoints['/'.self::TEST_USER1.'/files/ext']['priority']);
+
+ // Simulate changed mount options (without priority set)
+ $this->assertTrue(
+ OC_Mount_Config::addMountPoint(
+ '/ext',
+ $class,
+ $mountConfig,
+ OC_Mount_Config::MOUNT_TYPE_USER,
+ self::TEST_USER1,
+ false
+ )
+ );
+
+ // Check for correct priority
+ $mountPoints = OC_Mount_Config::getAbsoluteMountPoints(self::TEST_USER1);
+ $this->assertEquals($priority,
+ $mountPoints['/'.self::TEST_USER1.'/files/ext']['priority']);
+ }
}