Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-08-19 22:29:01 +0300
committerGitHub <noreply@github.com>2020-08-19 22:29:01 +0300
commitd7aa1c00edd535dbd806aedd957ead2ca26537e5 (patch)
treeadc3799c8e6daff49598aae7d0710a8d76dd2d71 /apps/files_trashbin
parent93225bcf22ec1f46ede58902f8642181f4d891b4 (diff)
parent193b3ead51fea5706d3ef14206684286b1b75c0e (diff)
Merge pull request #21983 from nextcloud/backport/21628/stable19
[stable19] fix moving files from external storage to object store trashbin
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r--apps/files_trashbin/lib/Trashbin.php20
1 files changed, 16 insertions, 4 deletions
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php
index f73cc1f4aa6..db6fa35e85c 100644
--- a/apps/files_trashbin/lib/Trashbin.php
+++ b/apps/files_trashbin/lib/Trashbin.php
@@ -44,6 +44,7 @@
namespace OCA\Files_Trashbin;
use OC\Files\Filesystem;
+use OC\Files\ObjectStore\ObjectStoreStorage;
use OC\Files\View;
use OCA\Files_Trashbin\AppInfo\Application;
use OCA\Files_Trashbin\Command\Expire;
@@ -278,12 +279,22 @@ class Trashbin {
/** @var \OC\Files\Storage\Storage $sourceStorage */
[$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/' . $ownerPath);
+
+ if ($trashStorage->file_exists($trashInternalPath)) {
+ $trashStorage->unlink($trashInternalPath);
+ }
+
+ $connection = \OC::$server->getDatabaseConnection();
+ $connection->beginTransaction();
+ $trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
+
try {
$moveSuccessful = true;
- if ($trashStorage->file_exists($trashInternalPath)) {
- $trashStorage->unlink($trashInternalPath);
+
+ // when moving within the same object store, the cache update done above is enough to move the file
+ if (!($trashStorage->instanceOfStorage(ObjectStoreStorage::class) && $trashStorage->getId() === $sourceStorage->getId())) {
+ $trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
}
- $trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
} catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
$moveSuccessful = false;
if ($trashStorage->file_exists($trashInternalPath)) {
@@ -298,10 +309,11 @@ class Trashbin {
} else {
$sourceStorage->unlink($sourceInternalPath);
}
+ $connection->rollBack();
return false;
}
- $trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
+ $connection->commit();
if ($moveSuccessful) {
$query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)");