only update share keys if the file was encrypted

This commit is contained in:
Bjoern Schiessle 2015-04-24 10:16:06 +02:00
parent 2646bccb83
commit 24128d1384
4 changed files with 25 additions and 6 deletions

View File

@ -235,6 +235,7 @@ class Storage implements IStorage {
*
* @param string $source
* @param string $target
* @return boolean
*/
public function renameKeys($source, $target) {
@ -253,7 +254,11 @@ class Storage implements IStorage {
if ($this->view->file_exists($sourcePath)) {
$this->keySetPreparation(dirname($targetPath));
$this->view->rename($sourcePath, $targetPath);
return true;
}
return false;
}
/**
@ -261,6 +266,7 @@ class Storage implements IStorage {
*
* @param string $source
* @param string $target
* @return boolean
*/
public function copyKeys($source, $target) {
@ -279,7 +285,10 @@ class Storage implements IStorage {
if ($this->view->file_exists($sourcePath)) {
$this->keySetPreparation(dirname($targetPath));
$this->view->copy($sourcePath, $targetPath);
return true;
}
return false;
}
/**

View File

@ -230,8 +230,11 @@ class Encryption extends Wrapper {
if (isset($this->unencryptedSize[$source])) {
$this->unencryptedSize[$target] = $this->unencryptedSize[$source];
}
$this->keyStorage->renameKeys($source, $target);
if (dirname($source) !== dirname($target) && $this->util->isFile($target)) {
$keysRenamed = $this->keyStorage->renameKeys($source, $target);
if ($keysRenamed &&
dirname($source) !== dirname($target) &&
$this->util->isFile($target)
) {
$this->update->update($target);
}
}
@ -256,8 +259,11 @@ class Encryption extends Wrapper {
$result = $this->storage->copy($path1, $path2);
if ($result) {
$target = $this->getFullPath($path2);
$this->keyStorage->copyKeys($source, $target);
if (dirname($source) !== dirname($target) && $this->util->isFile($target)) {
$keysCopied = $this->keyStorage->copyKeys($source, $target);
if ($keysCopied &&
dirname($source) !== dirname($target) &&
$this->util->isFile($target)
) {
$this->update->update($target);
}
}

View File

@ -153,6 +153,7 @@ interface IStorage {
*
* @param string $source
* @param string $target
* @return boolean
* @since 8.1.0
*/
public function renameKeys($source, $target);
@ -162,6 +163,7 @@ interface IStorage {
*
* @param string $source
* @param string $target
* @retrun boolean
* @since 8.1.0
*/
public function copyKeys($source, $target);

View File

@ -136,7 +136,8 @@ class Encryption extends \Test\Files\Storage\Storage {
public function testRename($source, $target, $shouldUpdate) {
$this->keyStore
->expects($this->once())
->method('renameKeys');
->method('renameKeys')
->willReturn(true);
$this->util->expects($this->any())
->method('isFile')->willReturn(true);
if ($shouldUpdate) {
@ -174,7 +175,8 @@ class Encryption extends \Test\Files\Storage\Storage {
public function testCopy($source, $target, $shouldUpdate) {
$this->keyStore
->expects($this->once())
->method('copyKeys');
->method('copyKeys')
->willReturn(true);
$this->util->expects($this->any())
->method('isFile')->willReturn(true);
if ($shouldUpdate) {