Skip to content

Commit

Permalink
Fix slow move on same object bucket during file upload.
Browse files Browse the repository at this point in the history
This commit fixes the issue nextcloud/server#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 <[email protected]>
  • Loading branch information
Christoph Fiehe committed Sep 10, 2024
1 parent 91c7662 commit 670e5c7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Mount/GroupFolderStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 670e5c7

Please sign in to comment.