diff options
author | Robin Appelman <robin@icewind.nl> | 2020-06-30 16:09:50 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2020-07-23 15:24:48 +0200 |
commit | fcad692b4a5dd8e0c128af64647b64f658b124c5 (patch) | |
tree | 5e76cad58489d46f046f61f967bd7bff512e5140 /apps | |
parent | 59498493220a666573516679e7752d09543ac1b5 (diff) | |
download | nextcloud-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.php | 5 |
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]); |