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,20 +691,22 @@ class View {
$data = $cache->get($internalPath);
if ($data['mimetype'] === 'httpd/unix-directory') {
//add the sizes of other mountpoints to the folder
$mountPoints = Filesystem::getMountPoints($path);
foreach ($mountPoints as $mountPoint) {
$subStorage = Filesystem::getStorage($mountPoint);
$subCache = $subStorage->getCache();
$rootEntry = $subCache->get('');
if ($data) {
if ($data['mimetype'] === 'httpd/unix-directory') {
//add the sizes of other mountpoints to the folder
$mountPoints = Filesystem::getMountPoints($path);
foreach ($mountPoints as $mountPoint) {
$subStorage = Filesystem::getStorage($mountPoint);
$subCache = $subStorage->getCache();
$rootEntry = $subCache->get('');
$data['size'] += $rootEntry['size'];
$data['size'] += $rootEntry['size'];
}
}
}
$permissionsCache = $storage->getPermissionsCache();
$data['permissions'] = $permissionsCache->get($data['fileid'], \OC_User::getUser());
$permissionsCache = $storage->getPermissionsCache();
$data['permissions'] = $permissionsCache->get($data['fileid'], \OC_User::getUser());
}
}
return $data;
}
@ -888,7 +890,7 @@ class View {
* @param string $path
* @return string
*/
public function getETag($path){
public function getETag($path) {
/**
* @var Storage\Storage $storage
* @var string $internalPath

View File

@ -192,6 +192,11 @@ class Cache extends \UnitTestCase {
$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() {
$this->cache->clear();
}

View File

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