Skip to content

Commit f3199a2

Browse files
committed
fix object store trashbin handling
object stores are "special" given how they interact with the cache on their own Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent d0acad0 commit f3199a2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

apps/files_trashbin/lib/Trashbin.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
namespace OCA\Files_Trashbin;
4545

4646
use OC\Files\Filesystem;
47+
use OC\Files\ObjectStore\ObjectStoreStorage;
4748
use OC\Files\View;
4849
use OCA\Files_Trashbin\AppInfo\Application;
4950
use OCA\Files_Trashbin\Command\Expire;
@@ -278,16 +279,22 @@ public static function move2trash($file_path, $ownerOnly = false) {
278279
/** @var \OC\Files\Storage\Storage $sourceStorage */
279280
[$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/' . $ownerPath);
280281

282+
283+
if ($trashStorage->file_exists($trashInternalPath)) {
284+
$trashStorage->unlink($trashInternalPath);
285+
}
286+
281287
$connection = \OC::$server->getDatabaseConnection();
282288
$connection->beginTransaction();
283289
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
284290

285291
try {
286292
$moveSuccessful = true;
287-
if ($trashStorage->file_exists($trashInternalPath)) {
288-
$trashStorage->unlink($trashInternalPath);
293+
294+
// when moving within the same object store, the cache update done above is enough to move the file
295+
if (!($trashStorage->instanceOfStorage(ObjectStoreStorage::class) && $trashStorage->getId() === $sourceStorage->getId())) {
296+
$trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
289297
}
290-
$trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
291298
} catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
292299
$moveSuccessful = false;
293300
if ($trashStorage->file_exists($trashInternalPath)) {

0 commit comments

Comments
 (0)