aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-09-19 19:33:34 +0200
committerLouis <louis@chmn.me>2024-10-08 18:14:26 +0200
commit821ce4dda8cb9f0e61108bea04001860df18dc0a (patch)
treed30eb3009b60b2e2b48a4abcbe8bfd0656c7a2b9
parent2a27a4129c23ac521c36be48d7c72e4db297f9c2 (diff)
downloadnextcloud-server-backport/48205/stable28.tar.gz
nextcloud-server-backport/48205/stable28.zip
fix: improve moving object store items to trashbinbackport/48205/stable28
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--apps/files_trashbin/lib/Trashbin.php19
1 files changed, 9 insertions, 10 deletions
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php
index 442b0b591c1..d19ef5cc02b 100644
--- a/apps/files_trashbin/lib/Trashbin.php
+++ b/apps/files_trashbin/lib/Trashbin.php
@@ -53,7 +53,6 @@ use OC\Files\Node\File;
use OC\Files\Node\Folder;
use OC\Files\Node\NonExistingFile;
use OC\Files\Node\NonExistingFolder;
-use OC\Files\ObjectStore\ObjectStoreStorage;
use OC\Files\View;
use OC_User;
use OCA\Files_Trashbin\AppInfo\Application;
@@ -67,6 +66,8 @@ use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
+use OCP\Files\Storage\ILockingStorage;
+use OCP\Files\Storage\IStorage;
use OCP\FilesMetadata\IFilesMetadataManager;
use OCP\IConfig;
use OCP\Lock\ILockingProvider;
@@ -290,11 +291,10 @@ class Trashbin {
$trashPath = '/files_trashbin/files/' . static::getTrashFilename($filename, $timestamp);
$gotLock = false;
- while (!$gotLock) {
+ do {
+ /** @var ILockingStorage & IStorage $trashStorage */
+ [$trashStorage, $trashInternalPath] = $ownerView->resolvePath($trashPath);
try {
- /** @var \OC\Files\Storage\Storage $trashStorage */
- [$trashStorage, $trashInternalPath] = $ownerView->resolvePath($trashPath);
-
$trashStorage->acquireLock($trashInternalPath, ILockingProvider::LOCK_EXCLUSIVE, $lockingProvider);
$gotLock = true;
} catch (LockedException $e) {
@@ -305,7 +305,7 @@ class Trashbin {
$trashPath = '/files_trashbin/files/' . static::getTrashFilename($filename, $timestamp);
}
- }
+ } while (!$gotLock);
$sourceStorage = $sourceInfo->getStorage();
$sourceInternalPath = $sourceInfo->getInternalPath();
@@ -319,13 +319,12 @@ class Trashbin {
return false;
}
-
try {
$moveSuccessful = true;
- // when moving within the same object store, the cache update done below 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);
+ if ($sourceStorage->getCache()->inCache($sourceInternalPath)) {
+ $trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
}
if ($trashStorage->getCache()->inCache($sourceInternalPath)) {
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);