Merge pull request #23185 from nextcloud/backport/23109/stable20

[stable20] dont hold a transaction during the move to trash
This commit is contained in:
Morris Jobke 2020-10-06 09:10:57 +02:00 committed by GitHub
commit 76fe051ecb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -285,8 +285,6 @@ class Trashbin {
$trashStorage->unlink($trashInternalPath); $trashStorage->unlink($trashInternalPath);
} }
$connection = \OC::$server->getDatabaseConnection();
$connection->beginTransaction();
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath); $trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
try { try {
@ -310,12 +308,16 @@ class Trashbin {
} else { } else {
$sourceStorage->unlink($sourceInternalPath); $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; return false;
} }
$connection->commit();
if ($moveSuccessful) { if ($moveSuccessful) {
$query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)"); $query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)");
$result = $query->execute([$filename, $timestamp, $location, $owner]); $result = $query->execute([$filename, $timestamp, $location, $owner]);