summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2020-09-30 14:30:54 +0200
committerJoas Schilling <coding@schilljs.com>2020-10-05 15:27:31 +0200
commitf6bf519e55a1a8f4bdad8e0e6f38f7e750c15d76 (patch)
treef00be3b779a77fae88195108f16653e2f626b331
parent3759bef671ba50f8b444151908d7d71b48548642 (diff)
downloadnextcloud-server-f6bf519e55a1a8f4bdad8e0e6f38f7e750c15d76.tar.gz
nextcloud-server-f6bf519e55a1a8f4bdad8e0e6f38f7e750c15d76.zip
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 <robin@icewind.nl>
-rw-r--r--apps/files_trashbin/lib/Trashbin.php12
1 files changed, 7 insertions, 5 deletions
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php
index d6c0644ccef..0a4244de9d9 100644
--- a/apps/files_trashbin/lib/Trashbin.php
+++ b/apps/files_trashbin/lib/Trashbin.php
@@ -284,8 +284,6 @@ class Trashbin {
$trashStorage->unlink($trashInternalPath);
}
- $connection = \OC::$server->getDatabaseConnection();
- $connection->beginTransaction();
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
try {
@@ -309,12 +307,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]);