diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2023-02-09 12:28:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-09 12:28:48 +0100 |
commit | 6ff9ca9bfc7e0490a485d8e26c2d2030c7aac425 (patch) | |
tree | a79d88ff648453076d1ccb44664703e5a3f14f35 | |
parent | e3f67b199161b979b4cbfb6d7a142921cc75d0fe (diff) | |
parent | 920e8ad21aed398da823acb441ca49ea4fa00f29 (diff) | |
download | nextcloud-server-6ff9ca9bfc7e0490a485d8e26c2d2030c7aac425.tar.gz nextcloud-server-6ff9ca9bfc7e0490a485d8e26c2d2030c7aac425.zip |
Merge pull request #36376 from nextcloud/backport/35894/stable24
[stable24] fix moving files of encrypted local storage to unencrypted local storage
-rw-r--r-- | lib/private/Files/Storage/Local.php | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 4611a6a86d9..5d997873f9a 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -43,6 +43,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; @@ -538,6 +539,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 @@ -546,10 +557,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 @@ -573,7 +581,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 |