summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2020-06-30 16:09:50 +0200
committerRobin Appelman <robin@icewind.nl>2020-07-23 15:24:48 +0200
commitfcad692b4a5dd8e0c128af64647b64f658b124c5 (patch)
tree5e76cad58489d46f046f61f967bd7bff512e5140 /apps
parent59498493220a666573516679e7752d09543ac1b5 (diff)
downloadnextcloud-server-fcad692b4a5dd8e0c128af64647b64f658b124c5.tar.gz
nextcloud-server-fcad692b4a5dd8e0c128af64647b64f658b124c5.zip
rollback cache rename if trashbin move fails
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_trashbin/lib/Trashbin.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php
index e23368f825b..db00a7ed272 100644
--- a/apps/files_trashbin/lib/Trashbin.php
+++ b/apps/files_trashbin/lib/Trashbin.php
@@ -278,6 +278,8 @@ class Trashbin {
/** @var \OC\Files\Storage\Storage $sourceStorage */
[$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/' . $ownerPath);
+ $connection = \OC::$server->getDatabaseConnection();
+ $connection->beginTransaction();
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
try {
@@ -300,9 +302,12 @@ class Trashbin {
} else {
$sourceStorage->unlink($sourceInternalPath);
}
+ $connection->rollBack();
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]);