]> source.dussan.org Git - nextcloud-server.git/commitdiff
Cache: make mounts overwrite existing folders, prevents duplicate entries
authorRobin Appelman <icewind@owncloud.com>
Tue, 22 Jan 2013 19:57:15 +0000 (20:57 +0100)
committerRobin Appelman <icewind@owncloud.com>
Tue, 22 Jan 2013 19:57:15 +0000 (20:57 +0100)
lib/files/view.php
tests/lib/files/view.php

index 06027910123985c455d0a33808f81c095ffab8e2..c50897603eb965bdfa73002f7005e677b28436a8 100644 (file)
@@ -794,6 +794,14 @@ class View {
                                                                $subPermissionsCache->set($rootEntry['fileid'], $user, $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;
                                                }
                                        }
index 53271142672c48445ebe076da1f8a74813ed4dea..586ad178425ace7680119cf3d00fc8f352a8cf2b 100644 (file)
@@ -98,6 +98,18 @@ class View extends \PHPUnit_Framework_TestCase {
                $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() {
                $storage1 = $this->getTestStorage(false);
                \OC\Files\Filesystem::mount($storage1, array(), '/');