aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2023-01-26 09:45:12 +0100
committerGitHub <noreply@github.com>2023-01-26 09:45:12 +0100
commit9ecec2fd753bb98446333ff95833abb198a1cdc5 (patch)
treeb26a0a8ac4fcfc11f60dafa6213692bf54419b57 /lib
parent40425035d234ca7af4cf1d7f1402a7a9b11ca18a (diff)
parent33b90d28f826f4f47c34ea4e51b0eb8dae7b9afa (diff)
downloadnextcloud-server-9ecec2fd753bb98446333ff95833abb198a1cdc5.tar.gz
nextcloud-server-9ecec2fd753bb98446333ff95833abb198a1cdc5.zip
Merge pull request #35894 from nextcloud/move-from-encryption
fix moving files of encrypted local storage to unencrypted local storage
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Storage/Local.php18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index 9daa3517825..b021d40d335 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -44,6 +44,7 @@
namespace OC\Files\Storage;
use OC\Files\Filesystem;
+use OC\Files\Storage\Wrapper\Encryption;
use OC\Files\Storage\Wrapper\Jail;
use OCP\Constants;
use OCP\Files\ForbiddenException;
@@ -543,6 +544,16 @@ class Local extends \OC\Files\Storage\Common {
}
}
+ private function canDoCrossStorageMove(IStorage $sourceStorage) {
+ return $sourceStorage->instanceOfStorage(Local::class)
+ // Don't treat ACLStorageWrapper like local storage where copy can be done directly.
+ // Instead, use the slower recursive copying in php from Common::copyFromStorage with
+ // more permissions checks.
+ && !$sourceStorage->instanceOfStorage('OCA\GroupFolders\ACL\ACLStorageWrapper')
+ // when moving encrypted files we have to handle keys and the target might not be encrypted
+ && !$sourceStorage->instanceOfStorage(Encryption::class);
+ }
+
/**
* @param IStorage $sourceStorage
* @param string $sourceInternalPath
@@ -551,10 +562,7 @@ class Local extends \OC\Files\Storage\Common {
* @return bool
*/
public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) {
- // Don't treat ACLStorageWrapper like local storage where copy can be done directly.
- // Instead use the slower recursive copying in php from Common::copyFromStorage with
- // more permissions checks.
- if ($sourceStorage->instanceOfStorage(Local::class) && !$sourceStorage->instanceOfStorage('OCA\GroupFolders\ACL\ACLStorageWrapper')) {
+ if ($this->canDoCrossStorageMove($sourceStorage)) {
if ($sourceStorage->instanceOfStorage(Jail::class)) {
/**
* @var \OC\Files\Storage\Wrapper\Jail $sourceStorage
@@ -578,7 +586,7 @@ class Local extends \OC\Files\Storage\Common {
* @return bool
*/
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
- if ($sourceStorage->instanceOfStorage(Local::class)) {
+ if ($this->canDoCrossStorageMove($sourceStorage)) {
if ($sourceStorage->instanceOfStorage(Jail::class)) {
/**
* @var \OC\Files\Storage\Wrapper\Jail $sourceStorage