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 \ILockingStorage ;
70+ use OCP \Files \Storage \IStorage ;
7071use OCP \FilesMetadata \IFilesMetadataManager ;
7172use OCP \IConfig ;
7273use OCP \Lock \ILockingProvider ;
@@ -290,11 +291,10 @@ public static function move2trash($file_path, $ownerOnly = false) {
290291 $ trashPath = '/files_trashbin/files/ ' . static ::getTrashFilename ($ filename , $ timestamp );
291292 $ gotLock = false ;
292293
293- while (!$ gotLock ) {
294+ do {
295+ /** @var ILockingStorage & IStorage $trashStorage */
296+ [$ trashStorage , $ trashInternalPath ] = $ ownerView ->resolvePath ($ trashPath );
294297 try {
295- /** @var \OC\Files\Storage\Storage $trashStorage */
296- [$ trashStorage , $ trashInternalPath ] = $ ownerView ->resolvePath ($ trashPath );
297-
298298 $ trashStorage ->acquireLock ($ trashInternalPath , ILockingProvider::LOCK_EXCLUSIVE , $ lockingProvider );
299299 $ gotLock = true ;
300300 } catch (LockedException $ e ) {
@@ -305,7 +305,7 @@ public static function move2trash($file_path, $ownerOnly = false) {
305305
306306 $ trashPath = '/files_trashbin/files/ ' . static ::getTrashFilename ($ filename , $ timestamp );
307307 }
308- }
308+ } while (! $ gotLock );
309309
310310 $ sourceStorage = $ sourceInfo ->getStorage ();
311311 $ sourceInternalPath = $ sourceInfo ->getInternalPath ();
@@ -319,13 +319,12 @@ public static function move2trash($file_path, $ownerOnly = false) {
319319 return false ;
320320 }
321321
322-
323322 try {
324323 $ moveSuccessful = true ;
325324
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 );
325+ $ trashStorage -> moveFromStorage ( $ sourceStorage , $ sourceInternalPath , $ trashInternalPath );
326+ if ($ sourceStorage -> getCache ()-> inCache ( $ sourceInternalPath )) {
327+ $ trashStorage ->getUpdater ()-> renameFromStorage ($ sourceStorage , $ sourceInternalPath , $ trashInternalPath );
329328 }
330329 if ($ trashStorage ->getCache ()->inCache ($ sourceInternalPath )) {
331330 $ trashStorage ->getUpdater ()->renameFromStorage ($ sourceStorage , $ sourceInternalPath , $ trashInternalPath );
0 commit comments