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>
This commit is contained in:
Robin Appelman 2020-09-30 14:30:54 +02:00 committed by Joas Schilling
parent 3759bef671
commit f6bf519e55
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
1 changed files with 7 additions and 5 deletions

View File

@ -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]);