summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-04-02 16:25:01 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-04-07 13:30:31 +0200
commitfe74a0cb4f319ac9dccfce8c296365c3535ef84e (patch)
treedf5c6034c6722c5687ce6f9c7415d4b8adf8d445 /lib/private
parent8991272269632bc094fb8ad537d5af5a1bc372b5 (diff)
downloadnextcloud-server-fe74a0cb4f319ac9dccfce8c296365c3535ef84e.tar.gz
nextcloud-server-fe74a0cb4f319ac9dccfce8c296365c3535ef84e.zip
implement webdav copy
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/encryption/keys/storage.php35
-rw-r--r--lib/private/files/storage/wrapper/encryption.php28
2 files changed, 53 insertions, 10 deletions
diff --git a/lib/private/encryption/keys/storage.php b/lib/private/encryption/keys/storage.php
index e4e3fb084f3..7d0612ae30e 100644
--- a/lib/private/encryption/keys/storage.php
+++ b/lib/private/encryption/keys/storage.php
@@ -283,7 +283,12 @@ class Storage implements \OCP\Encryption\Keys\IStorage {
* @param string $owner
* @param bool $systemWide
*/
- public function renameKeys($source, $target, $owner, $systemWide) {
+ public function renameKeys($source, $target) {
+
+ list($owner, $source) = $this->util->getUidAndFilename($source);
+ list(, $target) = $this->util->getUidAndFilename($target);
+ $systemWide = $this->util->isSystemWideMountPoint($target);
+
if ($systemWide) {
$sourcePath = $this->keys_base_dir . $source . '/';
$targetPath = $this->keys_base_dir . $target . '/';
@@ -299,6 +304,34 @@ class Storage implements \OCP\Encryption\Keys\IStorage {
}
/**
+ * copy keys if a file was renamed
+ *
+ * @param string $source
+ * @param string $target
+ * @param string $owner
+ * @param bool $systemWide
+ */
+ public function copyKeys($source, $target) {
+
+ list($owner, $source) = $this->util->getUidAndFilename($source);
+ list(, $target) = $this->util->getUidAndFilename($target);
+ $systemWide = $this->util->isSystemWideMountPoint($target);
+
+ if ($systemWide) {
+ $sourcePath = $this->keys_base_dir . $source . '/';
+ $targetPath = $this->keys_base_dir . $target . '/';
+ } else {
+ $sourcePath = '/' . $owner . $this->keys_base_dir . $source . '/';
+ $targetPath = '/' . $owner . $this->keys_base_dir . $target . '/';
+ }
+
+ if ($this->view->file_exists($sourcePath)) {
+ $this->keySetPreparation(dirname($targetPath));
+ $this->view->copy($sourcePath, $targetPath);
+ }
+ }
+
+ /**
* Make preparations to filesystem for saving a keyfile
*
* @param string $path relative to the views root
diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php
index 3ea3b987d4c..2e5bbfd97be 100644
--- a/lib/private/files/storage/wrapper/encryption.php
+++ b/lib/private/files/storage/wrapper/encryption.php
@@ -173,17 +173,14 @@ class Encryption extends Wrapper {
return $this->storage->rename($path1, $path2);
}
- $fullPath1 = $this->getFullPath($path1);
- list($owner, $source) = $this->util->getUidAndFilename($fullPath1);
+ $source = $this->getFullPath($path1);
$result = $this->storage->rename($path1, $path2);
if ($result) {
- $fullPath2 = $this->getFullPath($path2);
- $systemWide = $this->util->isSystemWideMountPoint($this->mountPoint);
- list(, $target) = $this->util->getUidAndFilename($fullPath2);
+ $target = $this->getFullPath($path2);
$encryptionModule = $this->getEncryptionModule($path2);
if ($encryptionModule) {
$keyStorage = $this->getKeyStorage($encryptionModule->getId());
- $keyStorage->renameKeys($source, $target, $owner, $systemWide);
+ $keyStorage->renameKeys($source, $target);
}
}
@@ -198,9 +195,22 @@ class Encryption extends Wrapper {
* @return bool
*/
public function copy($path1, $path2) {
- // todo copy encryption keys, get users with access to the file and reencrypt
- // or is this to encryption module specific? Then we can hand this over
- return $this->storage->copy($path1, $path2);
+ if ($this->util->isExcluded($path1)) {
+ return $this->storage->rename($path1, $path2);
+ }
+
+ $source = $this->getFullPath($path1);
+ $result = $this->storage->copy($path1, $path2);
+ if ($result) {
+ $target = $this->getFullPath($path2);
+ $encryptionModule = $this->getEncryptionModule($path2);
+ if ($encryptionModule) {
+ $keyStorage = $this->getKeyStorage($encryptionModule->getId());
+ $keyStorage->copyKeys($source, $target);
+ }
+ }
+
+ return $result;
}
/**