5353use OC \Files \Node \Folder ;
5454use OC \Files \Node \NonExistingFile ;
5555use OC \Files \Node \NonExistingFolder ;
56- use OC \Files \ObjectStore \ObjectStoreStorage ;
5756use OC \Files \View ;
5857use OC_User ;
5958use OCA \Files_Trashbin \AppInfo \Application ;
6766use OCP \Files \Node ;
6867use OCP \Files \NotFoundException ;
6968use OCP \Files \NotPermittedException ;
69+ use OCP \Files \Storage \IStorage ;
7070use OCP \FilesMetadata \IFilesMetadataManager ;
7171use OCP \IConfig ;
7272use OCP \Lock \ILockingProvider ;
@@ -290,11 +290,10 @@ public static function move2trash($file_path, $ownerOnly = false) {
290290 $ trashPath = '/files_trashbin/files/ ' . static ::getTrashFilename ($ filename , $ timestamp );
291291 $ gotLock = false ;
292292
293- while (!$ gotLock ) {
293+ do {
294+ /** @var IStorage $trashStorage */
295+ [$ trashStorage , $ trashInternalPath ] = $ ownerView ->resolvePath ($ trashPath );
294296 try {
295- /** @var \OC\Files\Storage\Storage $trashStorage */
296- [$ trashStorage , $ trashInternalPath ] = $ ownerView ->resolvePath ($ trashPath );
297-
298297 $ trashStorage ->acquireLock ($ trashInternalPath , ILockingProvider::LOCK_EXCLUSIVE , $ lockingProvider );
299298 $ gotLock = true ;
300299 } catch (LockedException $ e ) {
@@ -305,7 +304,7 @@ public static function move2trash($file_path, $ownerOnly = false) {
305304
306305 $ trashPath = '/files_trashbin/files/ ' . static ::getTrashFilename ($ filename , $ timestamp );
307306 }
308- }
307+ } while (! $ gotLock );
309308
310309 $ sourceStorage = $ sourceInfo ->getStorage ();
311310 $ sourceInternalPath = $ sourceInfo ->getInternalPath ();
@@ -319,13 +318,12 @@ public static function move2trash($file_path, $ownerOnly = false) {
319318 return false ;
320319 }
321320
322-
323321 try {
324322 $ moveSuccessful = true ;
325323
326- // when moving within the same object store, the cache update done below is enough to move the file
327- if (!( $ trashStorage -> instanceOfStorage (ObjectStoreStorage::class) && $ trashStorage -> getId () === $ sourceStorage -> getId () )) {
328- $ trashStorage ->moveFromStorage ($ sourceStorage , $ sourceInternalPath , $ trashInternalPath );
324+ $ trashStorage -> moveFromStorage ( $ sourceStorage , $ sourceInternalPath , $ trashInternalPath );
325+ if ($ sourceStorage -> getCache ()-> inCache ( $ sourceInternalPath )) {
326+ $ trashStorage ->getUpdater ()-> renameFromStorage ($ sourceStorage , $ sourceInternalPath , $ trashInternalPath );
329327 }
330328 if ($ trashStorage ->getCache ()->inCache ($ sourceInternalPath )) {
331329 $ trashStorage ->getUpdater ()->renameFromStorage ($ sourceStorage , $ sourceInternalPath , $ trashInternalPath );
0 commit comments