]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix object store trashbin handling 21982/head
authorRobin Appelman <robin@icewind.nl>
Thu, 30 Jul 2020 14:31:56 +0000 (16:31 +0200)
committerRobin Appelman <robin@icewind.nl>
Fri, 31 Jul 2020 15:33:30 +0000 (17:33 +0200)
object stores are "special" given how they interact with the cache on their own

Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_trashbin/lib/Trashbin.php

index 9eccebe64dfb745ff694c7b27e6440c2b5d7b782..27242a972d160e632ff58a77e1724c3b785d8f53 100644 (file)
@@ -44,6 +44,7 @@
 namespace OCA\Files_Trashbin;
 
 use OC\Files\Filesystem;
+use OC\Files\ObjectStore\ObjectStoreStorage;
 use OC\Files\View;
 use OCA\Files_Trashbin\AppInfo\Application;
 use OCA\Files_Trashbin\Command\Expire;
@@ -278,16 +279,22 @@ class Trashbin {
                /** @var \OC\Files\Storage\Storage $sourceStorage */
                [$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/' . $ownerPath);
 
+
+               if ($trashStorage->file_exists($trashInternalPath)) {
+                       $trashStorage->unlink($trashInternalPath);
+               }
+
                $connection = \OC::$server->getDatabaseConnection();
                $connection->beginTransaction();
                $trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
 
                try {
                        $moveSuccessful = true;
-                       if ($trashStorage->file_exists($trashInternalPath)) {
-                               $trashStorage->unlink($trashInternalPath);
+
+                       // when moving within the same object store, the cache update done above is enough to move the file
+                       if (!($trashStorage->instanceOfStorage(ObjectStoreStorage::class) && $trashStorage->getId() === $sourceStorage->getId())) {
+                               $trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
                        }
-                       $trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
                } catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
                        $moveSuccessful = false;
                        if ($trashStorage->file_exists($trashInternalPath)) {