From c87b1a50d908f0d99622d4c71534d47af1ab9218 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 19 Feb 2021 15:52:58 +0100 Subject: apply object store copy optimization when 'cross storage' copy is within the same object store Signed-off-by: Robin Appelman --- lib/private/Files/ObjectStore/ObjectStoreStorage.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/private/Files/ObjectStore') diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 3378f00c4dd..23483b3ab21 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -39,6 +39,7 @@ use OCP\Files\Cache\ICacheEntry; use OCP\Files\FileInfo; use OCP\Files\NotFoundException; use OCP\Files\ObjectStore\IObjectStore; +use OCP\Files\Storage\IStorage; class ObjectStoreStorage extends \OC\Files\Storage\Common { use CopyDirectory; @@ -530,6 +531,19 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { return $this->objectStore; } + public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) { + if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) { + /** @var ObjectStoreStorage $sourceStorage */ + if ($sourceStorage->getObjectStore()->getStorageId() === $this->getObjectStore()->getStorageId()) { + $sourceEntry = $sourceStorage->getCache()->get($sourceInternalPath); + $this->copyInner($sourceEntry, $targetInternalPath); + return true; + } + } + + return parent::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); + } + public function copy($path1, $path2) { $path1 = $this->normalizePath($path1); $path2 = $this->normalizePath($path2); -- cgit v1.2.3