]> source.dussan.org Git - nextcloud-server.git/commitdiff
Better reuse of cache data for getFolderContents
authorRobin Appelman <icewind@owncloud.com>
Thu, 16 Oct 2014 13:17:36 +0000 (15:17 +0200)
committerRobin Appelman <icewind@owncloud.com>
Fri, 24 Oct 2014 10:33:54 +0000 (12:33 +0200)
lib/private/files/view.php
tests/lib/files/view.php

index a9577b193c78889164359ec9b6c8bff2bd9be57c..5f5f29ded4f6d60c11d1458f0011a5c119d63ded 100644 (file)
@@ -964,15 +964,20 @@ class View {
                        $cache = $storage->getCache($internalPath);
                        $user = \OC_User::getUser();
 
-                       if ($cache->getStatus($internalPath) < Cache\Cache::COMPLETE) {
+                       $data = $cache->get($internalPath);
+                       $watcher = $storage->getWatcher($internalPath);
+                       if (!$data or $data['size'] === -1) {
+                               if (!$storage->file_exists($internalPath)) {
+                                       return array();
+                               }
                                $scanner = $storage->getScanner($internalPath);
                                $scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
-                       } else {
-                               $watcher = $storage->getWatcher($internalPath);
-                               $watcher->checkUpdate($internalPath);
+                               $data = $cache->get($internalPath);
+                       } else if ($watcher->checkUpdate($internalPath, $data)) {
+                               $data = $cache->get($internalPath);
                        }
 
-                       $folderId = $cache->getId($internalPath);
+                       $folderId = $data['fileid'];
                        /**
                         * @var \OC\Files\FileInfo[] $files
                         */
@@ -1034,7 +1039,7 @@ class View {
                                                                        break;
                                                                }
                                                        }
-                                                       $rootEntry['path'] = substr($path . '/' . $rootEntry['name'], strlen($user) + 2); // full path without /$user/
+                                                       $rootEntry['path'] = substr(Filesystem::normalizePath($path . '/' . $rootEntry['name']), strlen($user) + 2); // full path without /$user/
 
                                                        // if sharing was disabled for the user we remove the share permissions
                                                        if (\OCP\Util::isSharingDisabledForUser()) {
index 8d56ecd90032f409f49eac26eaba11c1d4a2da4b..5f030f29fa7520f1a0c080e7e32da243c89a05f5 100644 (file)
@@ -177,8 +177,9 @@ class View extends \PHPUnit_Framework_TestCase {
 
        function testCacheIncompleteFolder() {
                $storage1 = $this->getTestStorage(false);
-               \OC\Files\Filesystem::mount($storage1, array(), '/');
-               $rootView = new \OC\Files\View('');
+               \OC\Files\Filesystem::clearMounts();
+               \OC\Files\Filesystem::mount($storage1, array(), '/incomplete');
+               $rootView = new \OC\Files\View('/incomplete');
 
                $entries = $rootView->getDirectoryContent('/');
                $this->assertEquals(3, count($entries));