1010use Doctrine \DBAL \Exception \UniqueConstraintViolationException ;
1111use OC \DB \Exceptions \DbalException ;
1212use OC \DB \QueryBuilder \Sharded \ShardDefinition ;
13+ use OC \Files \Cache \Wrapper \CacheJail ;
14+ use OC \Files \Cache \Wrapper \CacheWrapper ;
1315use OC \Files \Search \SearchComparison ;
1416use OC \Files \Search \SearchQuery ;
1517use OC \Files \Storage \Wrapper \Encryption ;
@@ -1215,8 +1217,16 @@ public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEnt
12151217 }
12161218
12171219 private function moveFromStorageSharded (ShardDefinition $ shardDefinition , ICache $ sourceCache , ICacheEntry $ sourceEntry , $ targetPath ): void {
1220+ $ sourcePath = $ sourceEntry ->getPath ();
1221+ while ($ sourceCache instanceof CacheWrapper) {
1222+ if ($ sourceCache instanceof CacheJail) {
1223+ $ sourcePath = $ sourceCache ->getSourcePath ($ sourcePath );
1224+ }
1225+ $ sourceCache = $ sourceCache ->getCache ();
1226+ }
1227+
12181228 if ($ sourceEntry ->getMimeType () === ICacheEntry::DIRECTORY_MIMETYPE ) {
1219- $ fileIds = $ this ->getChildIds ($ sourceCache ->getNumericStorageId (), $ sourceEntry -> getPath () );
1229+ $ fileIds = $ this ->getChildIds ($ sourceCache ->getNumericStorageId (), $ sourcePath );
12201230 } else {
12211231 $ fileIds = [];
12221232 }
@@ -1234,9 +1244,9 @@ private function moveFromStorageSharded(ShardDefinition $shardDefinition, ICache
12341244 // when moving from an encrypted storage to a non-encrypted storage remove the `encrypted` mark
12351245 $ removeEncryptedFlag = ($ sourceCache instanceof Cache && $ sourceCache ->hasEncryptionWrapper ()) && !$ this ->hasEncryptionWrapper ();
12361246
1237- $ sourcePathLength = strlen ($ sourceEntry -> getPath () );
1247+ $ sourcePathLength = strlen ($ sourcePath );
12381248 foreach ($ cacheItems as &$ cacheItem ) {
1239- if ($ cacheItem ['path ' ] === $ sourceEntry -> getPath () ) {
1249+ if ($ cacheItem ['path ' ] === $ sourcePath ) {
12401250 $ cacheItem ['path ' ] = $ targetPath ;
12411251 $ cacheItem ['parent ' ] = $ this ->getParentId ($ targetPath );
12421252 $ cacheItem ['name ' ] = basename ($ cacheItem ['path ' ]);
0 commit comments