summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2023-02-07 18:32:44 +0100
committerGitHub <noreply@github.com>2023-02-07 18:32:44 +0100
commit4f7a5698b26d5f208432d85933e09d7e517ff61c (patch)
tree52dda7bdb3d0da14fc831c4a2f139d2ec9876636
parent3804de4b601f205d31280a814ba0b27dadf6c3a8 (diff)
parentaf823ec7f901d36ab07e0c78b965034d97cbeaee (diff)
downloadnextcloud-server-4f7a5698b26d5f208432d85933e09d7e517ff61c.tar.gz
nextcloud-server-4f7a5698b26d5f208432d85933e09d7e517ff61c.zip
Merge pull request #36374 from nextcloud/backport/35894/stable25
[stable25] fix moving files of encrypted local storage to unencrypted local storage
-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 0e118e76c5f..c3e808b4b95 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;
@@ -556,6 +557,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
@@ -564,10 +575,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
@@ -591,7 +599,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