diff options
author | Robin Appelman <robin@icewind.nl> | 2020-06-30 16:09:50 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2020-07-23 21:01:23 +0000 |
commit | b6a600e6535fb972e1e4c5c33dd6bd5cf7a097c2 (patch) | |
tree | 2feb82f6858a52afbb4f403b78333282d1d58db1 /apps/files_trashbin/lib | |
parent | c567b1d6b221ea5ffd48c88b17e404d85f2bb19a (diff) | |
download | nextcloud-server-b6a600e6535fb972e1e4c5c33dd6bd5cf7a097c2.tar.gz nextcloud-server-b6a600e6535fb972e1e4c5c33dd6bd5cf7a097c2.zip |
rollback cache rename if trashbin move fails
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_trashbin/lib')
-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 c027f1cae75..ca5b1be24f8 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]); |