fix cache behaviour for non existing files

This commit is contained in:
Robin Appelman 2012-12-11 01:06:21 +01:00
parent 317cd4c70a
commit 8635699db9
3 changed files with 22 additions and 12 deletions

View File

@ -691,6 +691,7 @@ class View {
$data = $cache->get($internalPath); $data = $cache->get($internalPath);
if ($data) {
if ($data['mimetype'] === 'httpd/unix-directory') { if ($data['mimetype'] === 'httpd/unix-directory') {
//add the sizes of other mountpoints to the folder //add the sizes of other mountpoints to the folder
$mountPoints = Filesystem::getMountPoints($path); $mountPoints = Filesystem::getMountPoints($path);
@ -706,6 +707,7 @@ class View {
$permissionsCache = $storage->getPermissionsCache(); $permissionsCache = $storage->getPermissionsCache();
$data['permissions'] = $permissionsCache->get($data['fileid'], \OC_User::getUser()); $data['permissions'] = $permissionsCache->get($data['fileid'], \OC_User::getUser());
} }
}
return $data; return $data;
} }

View File

@ -192,6 +192,11 @@ class Cache extends \UnitTestCase {
$this->assertEquals($file3, $this->cache->getIncomplete()); $this->assertEquals($file3, $this->cache->getIncomplete());
} }
function testNonExisting() {
$this->assertFalse($this->cache->get('foo.txt'));
$this->assertEquals(array(), $this->cache->getFolderContents('foo'));
}
public function tearDown() { public function tearDown() {
$this->cache->clear(); $this->cache->clear();
} }

View File

@ -92,6 +92,9 @@ class View extends \PHPUnit_Framework_TestCase {
$cachedData = $rootView->getFileInfo('/foo.txt'); $cachedData = $rootView->getFileInfo('/foo.txt');
$this->assertTrue($cachedData['encrypted']); $this->assertTrue($cachedData['encrypted']);
$this->assertEquals($cachedData['fileid'], $id); $this->assertEquals($cachedData['fileid'], $id);
$this->assertFalse($rootView->getFileInfo('/non/existing'));
$this->assertEquals(array(), $rootView->getDirectoryContent('/non/existing'));
} }
public function testAutoScan() { public function testAutoScan() {