Skip to content

Commit

Permalink
Merge pull request #23109 from nextcloud/trash-move-no-transaction
Browse files Browse the repository at this point in the history
dont hold a transaction during the move to trash
  • Loading branch information
nickvergessen authored Oct 5, 2020
2 parents 7511e71 + e0d688c commit bbfbb90
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions apps/files_trashbin/lib/Trashbin.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,6 @@ public static function move2trash($file_path, $ownerOnly = false) {
return false;
}

$connection = \OC::$server->getDatabaseConnection();
$connection->beginTransaction();
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);

try {
Expand All @@ -318,12 +316,16 @@ public static function move2trash($file_path, $ownerOnly = false) {
} 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]);
Expand Down

0 comments on commit bbfbb90

Please sign in to comment.