@@ -652,21 +652,22 @@ public function copyFromStorage(Storage\IStorage $sourceStorage, $sourceInternal
652652 * @param string $sourceInternalPath
653653 * @param string $targetInternalPath
654654 * @param bool $isRename
655+ * @param bool $keepEncryptionVersion
655656 */
656- private function updateEncryptedVersion (Storage \IStorage $ sourceStorage , $ sourceInternalPath , $ targetInternalPath , $ isRename ) {
657- $ isEncrypted = $ this ->encryptionManager ->isEnabled () && $ this ->shouldEncrypt ($ targetInternalPath ) ? 1 : 0 ;
657+ private function updateEncryptedVersion (Storage \IStorage $ sourceStorage , $ sourceInternalPath , $ targetInternalPath , $ isRename, $ keepEncryptionVersion ) {
658+ $ isEncrypted = $ this ->encryptionManager ->isEnabled () && $ this ->shouldEncrypt ($ targetInternalPath );
658659 $ cacheInformation = [
659- 'encrypted ' => ( bool ) $ isEncrypted ,
660+ 'encrypted ' => $ isEncrypted ,
660661 ];
661- if ($ isEncrypted === 1 ) {
662+ if ($ isEncrypted ) {
662663 $ encryptedVersion = $ sourceStorage ->getCache ()->get ($ sourceInternalPath )['encryptedVersion ' ];
663664
664665 // In case of a move operation from an unencrypted to an encrypted
665666 // storage the old encrypted version would stay with "0" while the
666667 // correct value would be "1". Thus we manually set the value to "1"
667668 // for those cases.
668669 // See also https://github.com/owncloud/core/issues/23078
669- if ($ encryptedVersion === 0 ) {
670+ if ($ encryptedVersion === 0 || ! $ keepEncryptionVersion ) {
670671 $ encryptedVersion = 1 ;
671672 }
672673
@@ -714,7 +715,7 @@ private function copyBetweenStorage(Storage\IStorage $sourceStorage, $sourceInte
714715 $ info ['size ' ]
715716 );
716717 }
717- $ this ->updateEncryptedVersion ($ sourceStorage , $ sourceInternalPath , $ targetInternalPath , $ isRename );
718+ $ this ->updateEncryptedVersion ($ sourceStorage , $ sourceInternalPath , $ targetInternalPath , $ isRename, true );
718719 }
719720 return $ result ;
720721 }
@@ -757,7 +758,7 @@ private function copyBetweenStorage(Storage\IStorage $sourceStorage, $sourceInte
757758 if ($ preserveMtime ) {
758759 $ this ->touch ($ targetInternalPath , $ sourceStorage ->filemtime ($ sourceInternalPath ));
759760 }
760- $ this ->updateEncryptedVersion ($ sourceStorage , $ sourceInternalPath , $ targetInternalPath , $ isRename );
761+ $ this ->updateEncryptedVersion ($ sourceStorage , $ sourceInternalPath , $ targetInternalPath , $ isRename, false );
761762 } else {
762763 // delete partially written target file
763764 $ this ->unlink ($ targetInternalPath );
0 commit comments