diff options
author | Robin Appelman <robin@icewind.nl> | 2020-09-30 14:30:54 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2020-09-30 14:30:54 +0200 |
commit | e0d688c3656ed4024ca82482c83a27418e30130f (patch) | |
tree | d00c2f9b94b5755bbde6ffb9069586f1d4b885d4 /apps/files_trashbin | |
parent | aeb7329b3db0b1cbfa41bdedf9bccb230a3910d8 (diff) | |
download | nextcloud-server-e0d688c3656ed4024ca82482c83a27418e30130f.tar.gz nextcloud-server-e0d688c3656ed4024ca82482c83a27418e30130f.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>
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r-- | apps/files_trashbin/lib/Trashbin.php | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index b1e1d0600b0..2626f439d11 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -293,8 +293,6 @@ class Trashbin { return false; } - $connection = \OC::$server->getDatabaseConnection(); - $connection->beginTransaction(); $trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath); try { @@ -318,12 +316,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]); |