only update share keys if the file was encrypted
This commit is contained in:
parent
2646bccb83
commit
24128d1384
|
@ -235,6 +235,7 @@ class Storage implements IStorage {
|
||||||
*
|
*
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* @param string $target
|
* @param string $target
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function renameKeys($source, $target) {
|
public function renameKeys($source, $target) {
|
||||||
|
|
||||||
|
@ -253,7 +254,11 @@ class Storage implements IStorage {
|
||||||
if ($this->view->file_exists($sourcePath)) {
|
if ($this->view->file_exists($sourcePath)) {
|
||||||
$this->keySetPreparation(dirname($targetPath));
|
$this->keySetPreparation(dirname($targetPath));
|
||||||
$this->view->rename($sourcePath, $targetPath);
|
$this->view->rename($sourcePath, $targetPath);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -261,6 +266,7 @@ class Storage implements IStorage {
|
||||||
*
|
*
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* @param string $target
|
* @param string $target
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function copyKeys($source, $target) {
|
public function copyKeys($source, $target) {
|
||||||
|
|
||||||
|
@ -279,7 +285,10 @@ class Storage implements IStorage {
|
||||||
if ($this->view->file_exists($sourcePath)) {
|
if ($this->view->file_exists($sourcePath)) {
|
||||||
$this->keySetPreparation(dirname($targetPath));
|
$this->keySetPreparation(dirname($targetPath));
|
||||||
$this->view->copy($sourcePath, $targetPath);
|
$this->view->copy($sourcePath, $targetPath);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -230,8 +230,11 @@ class Encryption extends Wrapper {
|
||||||
if (isset($this->unencryptedSize[$source])) {
|
if (isset($this->unencryptedSize[$source])) {
|
||||||
$this->unencryptedSize[$target] = $this->unencryptedSize[$source];
|
$this->unencryptedSize[$target] = $this->unencryptedSize[$source];
|
||||||
}
|
}
|
||||||
$this->keyStorage->renameKeys($source, $target);
|
$keysRenamed = $this->keyStorage->renameKeys($source, $target);
|
||||||
if (dirname($source) !== dirname($target) && $this->util->isFile($target)) {
|
if ($keysRenamed &&
|
||||||
|
dirname($source) !== dirname($target) &&
|
||||||
|
$this->util->isFile($target)
|
||||||
|
) {
|
||||||
$this->update->update($target);
|
$this->update->update($target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,8 +259,11 @@ class Encryption extends Wrapper {
|
||||||
$result = $this->storage->copy($path1, $path2);
|
$result = $this->storage->copy($path1, $path2);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$target = $this->getFullPath($path2);
|
$target = $this->getFullPath($path2);
|
||||||
$this->keyStorage->copyKeys($source, $target);
|
$keysCopied = $this->keyStorage->copyKeys($source, $target);
|
||||||
if (dirname($source) !== dirname($target) && $this->util->isFile($target)) {
|
if ($keysCopied &&
|
||||||
|
dirname($source) !== dirname($target) &&
|
||||||
|
$this->util->isFile($target)
|
||||||
|
) {
|
||||||
$this->update->update($target);
|
$this->update->update($target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,7 @@ interface IStorage {
|
||||||
*
|
*
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* @param string $target
|
* @param string $target
|
||||||
|
* @return boolean
|
||||||
* @since 8.1.0
|
* @since 8.1.0
|
||||||
*/
|
*/
|
||||||
public function renameKeys($source, $target);
|
public function renameKeys($source, $target);
|
||||||
|
@ -162,6 +163,7 @@ interface IStorage {
|
||||||
*
|
*
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* @param string $target
|
* @param string $target
|
||||||
|
* @retrun boolean
|
||||||
* @since 8.1.0
|
* @since 8.1.0
|
||||||
*/
|
*/
|
||||||
public function copyKeys($source, $target);
|
public function copyKeys($source, $target);
|
||||||
|
|
|
@ -136,7 +136,8 @@ class Encryption extends \Test\Files\Storage\Storage {
|
||||||
public function testRename($source, $target, $shouldUpdate) {
|
public function testRename($source, $target, $shouldUpdate) {
|
||||||
$this->keyStore
|
$this->keyStore
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('renameKeys');
|
->method('renameKeys')
|
||||||
|
->willReturn(true);
|
||||||
$this->util->expects($this->any())
|
$this->util->expects($this->any())
|
||||||
->method('isFile')->willReturn(true);
|
->method('isFile')->willReturn(true);
|
||||||
if ($shouldUpdate) {
|
if ($shouldUpdate) {
|
||||||
|
@ -174,7 +175,8 @@ class Encryption extends \Test\Files\Storage\Storage {
|
||||||
public function testCopy($source, $target, $shouldUpdate) {
|
public function testCopy($source, $target, $shouldUpdate) {
|
||||||
$this->keyStore
|
$this->keyStore
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('copyKeys');
|
->method('copyKeys')
|
||||||
|
->willReturn(true);
|
||||||
$this->util->expects($this->any())
|
$this->util->expects($this->any())
|
||||||
->method('isFile')->willReturn(true);
|
->method('isFile')->willReturn(true);
|
||||||
if ($shouldUpdate) {
|
if ($shouldUpdate) {
|
||||||
|
|
Loading…
Reference in New Issue