make sure that we keep the correct encrypted-flag and the (unencrypted)size if a file gets copied
This commit is contained in:
parent
5aa3525479
commit
7089af96f2
2 changed files with 45 additions and 11 deletions
|
@ -252,6 +252,7 @@ class Encryption extends Wrapper {
|
||||||
*/
|
*/
|
||||||
public function copy($path1, $path2) {
|
public function copy($path1, $path2) {
|
||||||
$fullPath1 = $this->getFullPath($path1);
|
$fullPath1 = $this->getFullPath($path1);
|
||||||
|
$fullPath2 = $this->getFullPath($path2);
|
||||||
if ($this->util->isExcluded($fullPath1)) {
|
if ($this->util->isExcluded($fullPath1)) {
|
||||||
return $this->storage->copy($path1, $path2);
|
return $this->storage->copy($path1, $path2);
|
||||||
}
|
}
|
||||||
|
@ -267,6 +268,9 @@ class Encryption extends Wrapper {
|
||||||
) {
|
) {
|
||||||
$this->update->update($target);
|
$this->update->update($target);
|
||||||
}
|
}
|
||||||
|
$data = $this->getMetaData($path1);
|
||||||
|
$this->getCache()->put($path2, ['encrypted' => $data['encrypted']]);
|
||||||
|
$this->updateUnencryptedSize($fullPath2, $data['size']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Encryption extends \Test\Files\Storage\Storage {
|
||||||
private $sourceStorage;
|
private $sourceStorage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \OC\Files\Storage\Wrapper\Encryption
|
* @var \OC\Files\Storage\Wrapper\Encryption | \PHPUnit_Framework_MockObject_MockObject
|
||||||
*/
|
*/
|
||||||
protected $instance;
|
protected $instance;
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ class Encryption extends \Test\Files\Storage\Storage {
|
||||||
*/
|
*/
|
||||||
private $util;
|
private $util;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \OC\Encryption\Manager | \PHPUnit_Framework_MockObject_MockObject
|
* @var \OC\Encryption\Manager | \PHPUnit_Framework_MockObject_MockObject
|
||||||
*/
|
*/
|
||||||
|
@ -38,12 +37,16 @@ class Encryption extends \Test\Files\Storage\Storage {
|
||||||
*/
|
*/
|
||||||
private $encryptionModule;
|
private $encryptionModule;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \OC\Encryption\Update | \PHPUnit_Framework_MockObject_MockObject
|
* @var \OC\Encryption\Update | \PHPUnit_Framework_MockObject_MockObject
|
||||||
*/
|
*/
|
||||||
private $update;
|
private $update;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \OC\Files\Cache\Cache | \PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
|
private $cache;
|
||||||
|
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
@ -92,14 +95,25 @@ class Encryption extends \Test\Files\Storage\Storage {
|
||||||
->setMethods(['getOption'])
|
->setMethods(['getOption'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$mount->expects($this->any())->method('getOption')->willReturn(true);
|
$mount->expects($this->any())->method('getOption')->willReturn(true);
|
||||||
$this->instance = new \OC\Files\Storage\Wrapper\Encryption([
|
$this->cache = $this->getMockBuilder('\OC\Files\Cache\Cache')
|
||||||
'storage' => $this->sourceStorage,
|
->disableOriginalConstructor()->getMock();
|
||||||
'root' => 'foo',
|
$this->cache->expects($this->any())->method('get')->willReturn(array());
|
||||||
'mountPoint' => '/',
|
|
||||||
'mount' => $mount
|
$this->instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption')
|
||||||
],
|
->setConstructorArgs([
|
||||||
$this->encryptionManager, $this->util, $logger, $file, null, $this->keyStore, $this->update
|
[
|
||||||
);
|
'storage' => $this->sourceStorage,
|
||||||
|
'root' => 'foo',
|
||||||
|
'mountPoint' => '/',
|
||||||
|
'mount' => $mount
|
||||||
|
],
|
||||||
|
$this->encryptionManager, $this->util, $logger, $file, null, $this->keyStore, $this->update
|
||||||
|
])
|
||||||
|
->setMethods(['getMetaData', 'getCache'])
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$this->instance->expects($this->any())->method('getCache')->willReturn($this->cache);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,6 +174,18 @@ class Encryption extends \Test\Files\Storage\Storage {
|
||||||
* @param boolean $shouldUpdate
|
* @param boolean $shouldUpdate
|
||||||
*/
|
*/
|
||||||
public function testCopyTesting($source, $target, $copyKeysReturn, $shouldUpdate) {
|
public function testCopyTesting($source, $target, $copyKeysReturn, $shouldUpdate) {
|
||||||
|
|
||||||
|
$dummySize = -1;
|
||||||
|
|
||||||
|
$this->instance->expects($this->any())
|
||||||
|
->method('getMetaData')
|
||||||
|
->willReturn(['encrypted' => true, 'size' => $dummySize]);
|
||||||
|
|
||||||
|
$this->cache->expects($this->once())
|
||||||
|
->method('put')
|
||||||
|
->with($this->anything(), ['encrypted' => true])
|
||||||
|
->willReturn(true);
|
||||||
|
|
||||||
$this->keyStore
|
$this->keyStore
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('copyKeys')
|
->method('copyKeys')
|
||||||
|
@ -177,6 +203,10 @@ class Encryption extends \Test\Files\Storage\Storage {
|
||||||
$this->instance->mkdir($source);
|
$this->instance->mkdir($source);
|
||||||
$this->instance->mkdir(dirname($target));
|
$this->instance->mkdir(dirname($target));
|
||||||
$this->instance->copy($source, $target);
|
$this->instance->copy($source, $target);
|
||||||
|
|
||||||
|
$this->assertSame($dummySize,
|
||||||
|
$this->instance->filesize($target)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue