Skip to content
Snippets Groups Projects
Commit 7330fcf5 authored by Robin Appelman's avatar Robin Appelman
Browse files

Cache: make mounts overwrite existing folders, prevents duplicate entries

parent db2b485b
No related branches found
No related tags found
No related merge requests found
...@@ -794,6 +794,14 @@ class View { ...@@ -794,6 +794,14 @@ class View {
$subPermissionsCache->set($rootEntry['fileid'], $user, $permissions); $subPermissionsCache->set($rootEntry['fileid'], $user, $permissions);
} }
$rootEntry['permissions'] = $permissions; $rootEntry['permissions'] = $permissions;
//remove any existing entry with the same name
foreach ($files as $i => $file) {
if ($file['name'] === $rootEntry['name']) {
unset($files[$i]);
break;
}
}
$files[] = $rootEntry; $files[] = $rootEntry;
} }
} }
......
...@@ -98,6 +98,18 @@ class View extends \PHPUnit_Framework_TestCase { ...@@ -98,6 +98,18 @@ class View extends \PHPUnit_Framework_TestCase {
$this->assertEquals(array(), $rootView->getDirectoryContent('/non/existing')); $this->assertEquals(array(), $rootView->getDirectoryContent('/non/existing'));
} }
function testMountPointOverwrite() {
$storage1 = $this->getTestStorage(false);
$storage2 = $this->getTestStorage();
$storage1->mkdir('substorage');
\OC\Files\Filesystem::mount($storage1, array(), '/');
\OC\Files\Filesystem::mount($storage2, array(), '/substorage');
$rootView = new \OC\Files\View('');
$folderContent = $rootView->getDirectoryContent('/');
$this->assertEquals(4, count($folderContent));
}
function testCacheIncompleteFolder() { function testCacheIncompleteFolder() {
$storage1 = $this->getTestStorage(false); $storage1 = $this->getTestStorage(false);
\OC\Files\Filesystem::mount($storage1, array(), '/'); \OC\Files\Filesystem::mount($storage1, array(), '/');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment