diff options
author | Robin Appelman <robin@icewind.nl> | 2024-09-19 19:33:34 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2024-09-19 21:01:44 +0200 |
commit | 42ea824fd7c4d683a69d12450ce544aa9f578b1e (patch) | |
tree | 2a19581519607a52ce7194600f91e5c193bb0d3b | |
parent | 00a27afa264c98cd1ca65a682f459f60ef91b497 (diff) | |
download | nextcloud-server-42ea824fd7c4d683a69d12450ce544aa9f578b1e.tar.gz nextcloud-server-42ea824fd7c4d683a69d12450ce544aa9f578b1e.zip |
fix: improve moving object store items to trashbinobject-store-trash-move
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | apps/files_trashbin/lib/Trashbin.php | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 29e4d5e8a3c..de79f22ae5b 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -15,7 +15,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; @@ -30,6 +29,7 @@ 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\IDBConnection; @@ -256,11 +256,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 ILockingStorage $trashStorage */ - [$trashStorage, $trashInternalPath] = $ownerView->resolvePath($trashPath); - $trashStorage->acquireLock($trashInternalPath, ILockingProvider::LOCK_EXCLUSIVE, $lockingProvider); $gotLock = true; } catch (LockedException $e) { @@ -271,7 +270,7 @@ class Trashbin { $trashPath = '/files_trashbin/files/' . static::getTrashFilename($filename, $timestamp); } - } + } while (!$gotLock); $sourceStorage = $sourceInfo->getStorage(); $sourceInternalPath = $sourceInfo->getInternalPath(); @@ -285,14 +284,12 @@ class Trashbin { return false; } - $trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath); - try { $moveSuccessful = true; - // 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); + if ($sourceStorage->getCache()->inCache($sourceInternalPath)) { + $trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath); } } catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) { $moveSuccessful = false; |