@@ -1173,8 +1173,21 @@ public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, str
11731173 throw new \RuntimeException ('Failed to copy to ' . $ targetPath . ' from cache with source data ' . json_encode ($ data ) . ' ' );
11741174 }
11751175 if ($ sourceEntry ->getMimeType () === ICacheEntry::DIRECTORY_MIMETYPE ) {
1176+ if (($ sourceEntry instanceof CacheEntry) && isset ($ sourceEntry ['copy_from_storage_permissions ' ])) {
1177+ $ permissionsToSet = $ sourceEntry ['copy_from_storage_permissions ' ];
1178+ } else {
1179+ $ permissionsToSet = null ;
1180+ }
11761181 $ folderContent = $ sourceCache ->getFolderContentsById ($ sourceEntry ->getId ());
11771182 foreach ($ folderContent as $ subEntry ) {
1183+ if ($ permissionsToSet !== null ) {
1184+ $ perms = $ permissionsToSet ;
1185+ if ($ subEntry ->getMimeType () !== ICacheEntry::DIRECTORY_MIMETYPE ) {
1186+ $ perms &= ~\OCP \Constants::PERMISSION_CREATE ;
1187+ }
1188+ $ subEntry ['copy_from_storage_permissions ' ] = $ perms ;
1189+ unset($ subEntry ['scan_permissions ' ]);
1190+ }
11781191 $ subTargetPath = $ targetPath . '/ ' . $ subEntry ->getName ();
11791192 $ this ->copyFromCache ($ sourceCache , $ subEntry , $ subTargetPath );
11801193 }
@@ -1196,9 +1209,14 @@ private function cacheEntryToArray(ICacheEntry $entry): array {
11961209 'upload_time ' => $ entry ->getUploadTime (),
11971210 'metadata_etag ' => $ entry ->getMetadataEtag (),
11981211 ];
1199- if ($ entry instanceof CacheEntry && isset ($ entry ['scan_permissions ' ])) {
1200- $ data ['permissions ' ] = $ entry ['scan_permissions ' ];
1212+ if ($ entry instanceof CacheEntry) {
1213+ if (isset ($ entry ['copy_from_storage_permissions ' ])) {
1214+ $ data ['permissions ' ] = $ entry ['copy_from_storage_permissions ' ];
1215+ } elseif (isset ($ entry ['scan_permissions ' ])) {
1216+ $ data ['permissions ' ] = $ entry ['scan_permissions ' ];
1217+ }
12011218 }
1219+
12021220 return $ data ;
12031221 }
12041222
0 commit comments