Skip to content

Commit 74c92e8

Browse files
committed
fix moving files of encrypted local storage to unencrypted local storage
for example when moving encrypted files to a groupfolder Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent c31e0e3 commit 74c92e8

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

lib/private/Files/Storage/Local.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
namespace OC\Files\Storage;
4545

4646
use OC\Files\Filesystem;
47+
use OC\Files\Storage\Wrapper\Encryption;
4748
use OC\Files\Storage\Wrapper\Jail;
4849
use OCP\Constants;
4950
use OCP\Files\ForbiddenException;
@@ -543,6 +544,16 @@ private function calculateEtag(string $path, array $stat): string {
543544
}
544545
}
545546

547+
private function canDoCrossStorageMove(IStorage $sourceStorage) {
548+
return $sourceStorage->instanceOfStorage(Local::class)
549+
// Don't treat ACLStorageWrapper like local storage where copy can be done directly.
550+
// Instead, use the slower recursive copying in php from Common::copyFromStorage with
551+
// more permissions checks.
552+
&& !$sourceStorage->instanceOfStorage('OCA\GroupFolders\ACL\ACLStorageWrapper')
553+
// when moving encrypted files we have to handle keys and the target might not be encrypted
554+
&& !$sourceStorage->instanceOfStorage(Encryption::class);
555+
}
556+
546557
/**
547558
* @param IStorage $sourceStorage
548559
* @param string $sourceInternalPath
@@ -551,10 +562,7 @@ private function calculateEtag(string $path, array $stat): string {
551562
* @return bool
552563
*/
553564
public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) {
554-
// Don't treat ACLStorageWrapper like local storage where copy can be done directly.
555-
// Instead use the slower recursive copying in php from Common::copyFromStorage with
556-
// more permissions checks.
557-
if ($sourceStorage->instanceOfStorage(Local::class) && !$sourceStorage->instanceOfStorage('OCA\GroupFolders\ACL\ACLStorageWrapper')) {
565+
if ($this->canDoCrossStorageMove($sourceStorage)) {
558566
if ($sourceStorage->instanceOfStorage(Jail::class)) {
559567
/**
560568
* @var \OC\Files\Storage\Wrapper\Jail $sourceStorage
@@ -578,7 +586,7 @@ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
578586
* @return bool
579587
*/
580588
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
581-
if ($sourceStorage->instanceOfStorage(Local::class)) {
589+
if ($this->canDoCrossStorageMove($sourceStorage)) {
582590
if ($sourceStorage->instanceOfStorage(Jail::class)) {
583591
/**
584592
* @var \OC\Files\Storage\Wrapper\Jail $sourceStorage

0 commit comments

Comments
 (0)