4444namespace OC \Files \Storage ;
4545
4646use OC \Files \Filesystem ;
47+ use OC \Files \Storage \Wrapper \Encryption ;
4748use OC \Files \Storage \Wrapper \Jail ;
4849use OCP \Constants ;
4950use 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