Merge pull request #18702 from owncloud/ext-emptymount
Allow an empty mount point
This commit is contained in:
commit
3e9533ae11
3 changed files with 35 additions and 2 deletions
|
@ -172,7 +172,7 @@ abstract class StoragesService {
|
||||||
|
|
||||||
// the root mount point is in the format "/$user/files/the/mount/point"
|
// the root mount point is in the format "/$user/files/the/mount/point"
|
||||||
// we remove the "/$user/files" prefix
|
// we remove the "/$user/files" prefix
|
||||||
$parts = explode('/', trim($rootMountPath, '/'), 3);
|
$parts = explode('/', ltrim($rootMountPath, '/'), 3);
|
||||||
if (count($parts) < 3) {
|
if (count($parts) < 3) {
|
||||||
// something went wrong, skip
|
// something went wrong, skip
|
||||||
\OCP\Util::writeLog(
|
\OCP\Util::writeLog(
|
||||||
|
@ -183,7 +183,7 @@ abstract class StoragesService {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$relativeMountPath = $parts[2];
|
$relativeMountPath = rtrim($parts[2], '/');
|
||||||
|
|
||||||
// note: we cannot do this after the loop because the decrypted config
|
// note: we cannot do this after the loop because the decrypted config
|
||||||
// options might be needed for the config hash
|
// options might be needed for the config hash
|
||||||
|
|
|
@ -914,4 +914,32 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
|
||||||
$this->assertEquals('identifier:\Auth\Mechanism', $storage2->getAuthMechanism()->getIdentifier());
|
$this->assertEquals('identifier:\Auth\Mechanism', $storage2->getAuthMechanism()->getIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testReadEmptyMountPoint() {
|
||||||
|
$configFile = $this->dataDir . '/mount.json';
|
||||||
|
|
||||||
|
$json = [
|
||||||
|
'user' => [
|
||||||
|
'user1' => [
|
||||||
|
'/$user/files/' => [
|
||||||
|
'backend' => 'identifier:\OCA\Files_External\Lib\Backend\SFTP',
|
||||||
|
'authMechanism' => 'identifier:\Auth\Mechanism',
|
||||||
|
'options' => [],
|
||||||
|
'mountOptions' => [],
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
file_put_contents($configFile, json_encode($json));
|
||||||
|
|
||||||
|
$allStorages = $this->service->getAllStorages();
|
||||||
|
|
||||||
|
$this->assertCount(1, $allStorages);
|
||||||
|
|
||||||
|
$storage1 = $allStorages[1];
|
||||||
|
|
||||||
|
$this->assertEquals('/', $storage1->getMountPoint());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,4 +212,9 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
|
||||||
$this->assertTrue(true);
|
$this->assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testReadEmptyMountPoint() {
|
||||||
|
// we don't test this here
|
||||||
|
$this->assertTrue(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue