Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[email protected]>
  • Loading branch information
icewind1991 authored and skjnldsv committed Oct 19, 2020
commit c8d121a7d7d620b47ec250d675e5550505844a9e
12 changes: 7 additions & 5 deletions apps/files_trashbin/lib/Trashbin.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,6 @@ public static function move2trash($file_path, $ownerOnly = false) {
$trashStorage->unlink($trashInternalPath);
}

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

try {
Expand All @@ -309,12 +307,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(array($filename, $timestamp, $location, $owner));
Expand Down