diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-01-16 13:33:17 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-04-13 15:13:02 +0200 |
commit | 31e94708f86e21174e4bcfaf33f645dbba1efc1e (patch) | |
tree | 9aa5bedacd55deda348d64bcd1fbe0fe506416c3 /lib/private | |
parent | 8575bb2cb9f57d2b7e6d9e9e48e7c85485a7c63b (diff) | |
download | nextcloud-server-31e94708f86e21174e4bcfaf33f645dbba1efc1e.tar.gz nextcloud-server-31e94708f86e21174e4bcfaf33f645dbba1efc1e.zip |
Improve cross storage copy between local storages
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/files/storage/local.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index 6bd9b4401d6..8815361bc1d 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -353,5 +353,41 @@ if (\OC_Util::runningOnWindows()) { return parent::getETag($path); } } + + /** + * @param \OCP\Files\Storage $sourceStorage + * @param string $sourceInternalPath + * @param string $targetInternalPath + * @return bool + */ + public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) { + if($sourceStorage->instanceOfStorage('\OC\Files\Storage\Local')){ + /** + * @var \OC\Files\Storage\Local $sourceStorage + */ + $rootStorage = new Local(['datadir' => '/']); + return $rootStorage->copy($sourceStorage->getSourcePath($sourceInternalPath), $this->getSourcePath($targetInternalPath)); + } else { + return parent::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); + } + } + + /** + * @param \OCP\Files\Storage $sourceStorage + * @param string $sourceInternalPath + * @param string $targetInternalPath + * @return bool + */ + public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) { + if ($sourceStorage->instanceOfStorage('\OC\Files\Storage\Local')) { + /** + * @var \OC\Files\Storage\Local $sourceStorage + */ + $rootStorage = new Local(['datadir' => '/']); + return $rootStorage->rename($sourceStorage->getSourcePath($sourceInternalPath), $this->getSourcePath($targetInternalPath)); + } else { + return parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); + } + } } } |