always update file cache, the cache can handle partial data correctly if the file doesn't already exists in the file cache

This commit is contained in:
Bjoern Schiessle 2015-07-31 15:44:27 +02:00
parent de01951da3
commit 51a67a54e0
2 changed files with 9 additions and 8 deletions

View File

@ -127,12 +127,11 @@ class Encryption extends Wrapper {
$info = $this->getCache()->get($path);
if (isset($this->unencryptedSize[$fullPath])) {
$size = $this->unencryptedSize[$fullPath];
// update file cache
$info['encrypted'] = true;
$info['size'] = $size;
$this->getCache()->put($path, $info);
if (isset($info['fileid'])) {
$info['encrypted'] = true;
$info['size'] = $size;
$this->getCache()->put($path, $info);
}
return $size;
}

View File

@ -261,10 +261,12 @@ class Encryption extends \Test\Files\Storage\Storage {
->expects($this->once())
->method('copyKeys')
->willReturn($copyKeysReturn);
$this->cache->expects($this->once())
$this->cache->expects($this->atLeastOnce())
->method('put')
->with($this->anything(), ['encrypted' => true])
->willReturn(true);
->willReturnCallback(function($path, $data) {
$this->assertArrayHasKey('encrypted', $data);
$this->assertTrue($data['encrypted']);
});
} else {
$this->cache->expects($this->never())->method('put');
$this->keyStore->expects($this->never())->method('copyKeys');