From 670e5c7d5224f0e150b6403d93fd872ec3414166 Mon Sep 17 00:00:00 2001 From: Christoph Fiehe Date: Tue, 10 Sep 2024 23:06:43 +0200 Subject: [PATCH] Fix slow move on same object bucket during file upload. This commit fixes the issue https://github.com/nextcloud/server/issues/47856. When you upload a file into a group folder and when you use a single S3 bucket as primary storage, the final move operation hangs for a long time. In the background, Nextcloud initiates a copy-delete sequence from the bucket into the bucket, with causes a lot unnecessary overhead. Nextcloud thinks that the file must be imported to another storage and does not recognize that everything is done on the same object bucket. In that case, the import step can be completely skipped, which saves time, network bandwidth and reduces the load on the object storage. Signed-off-by: Christoph Fiehe --- lib/Mount/GroupFolderStorage.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/Mount/GroupFolderStorage.php b/lib/Mount/GroupFolderStorage.php index 36c0df4bb..aa607ee34 100644 --- a/lib/Mount/GroupFolderStorage.php +++ b/lib/Mount/GroupFolderStorage.php @@ -69,4 +69,14 @@ public function getScanner($path = '', $storage = null) { } return $storage->scanner; } + + public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { + if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class) && + $this->instanceOfStorage(ObjectStoreStorage::class) && + $sourceStorage->getObjectStore()->getStorageId() == $this->getObjectStore()->getStorageId()) { + // Do not import any data when source and target object storages are identical. + return true; + } + return parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); + } }