From acef3620e07c214822c7a26c258681c454136194 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 30 Sep 2020 14:30:54 +0200 Subject: [PATCH] dont hold a transaction during the move to trash because moving to trash can take a long time, keeping a transaction active for the duration can lead to issues Signed-off-by: Robin Appelman --- apps/files_trashbin/lib/Trashbin.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 276cdf4e2d..284ef82a24 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -285,8 +285,6 @@ class Trashbin { $trashStorage->unlink($trashInternalPath); } - $connection = \OC::$server->getDatabaseConnection(); - $connection->beginTransaction(); $trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath); try { @@ -310,12 +308,16 @@ class Trashbin { } else { $sourceStorage->unlink($sourceInternalPath); } - $connection->rollBack(); + + if ($sourceStorage->file_exists($sourceInternalPath)) { + // undo the cache move + $sourceStorage->getUpdater()->renameFromStorage($trashStorage, $trashInternalPath, $sourceInternalPath); + } else { + $trashStorage->getUpdater()->remove($trashInternalPath); + } return false; } - $connection->commit(); - if ($moveSuccessful) { $query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)"); $result = $query->execute([$filename, $timestamp, $location, $owner]);