summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-05-19 14:21:58 +0200
committerRobin Appelman <icewind@owncloud.com>2015-05-19 14:21:58 +0200
commit9c751f1d871179523e55f93777a473e808d4441b (patch)
treee5fd2799530f0c2288216672773ea03be9190bba /lib
parent8f1a609512744f38976582e9e31b2c14c8f90d01 (diff)
downloadnextcloud-server-9c751f1d871179523e55f93777a473e808d4441b.tar.gz
nextcloud-server-9c751f1d871179523e55f93777a473e808d4441b.zip
use copy when doing a crossStorageCopy on the same storage
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/storage/common.php15
-rw-r--r--lib/private/files/storage/wrapper/wrapper.php8
2 files changed, 20 insertions, 3 deletions
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php
index fc30b385e2e..893e4ea7d9b 100644
--- a/lib/private/files/storage/common.php
+++ b/lib/private/files/storage/common.php
@@ -498,18 +498,18 @@ abstract class Common implements Storage {
* @throws InvalidPathException
*/
private function scanForInvalidCharacters($fileName, $invalidChars) {
- foreach(str_split($invalidChars) as $char) {
+ foreach (str_split($invalidChars) as $char) {
if (strpos($fileName, $char) !== false) {
throw new InvalidCharacterInPathException();
}
}
$sanitizedFileName = filter_var($fileName, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW);
- if($sanitizedFileName !== $fileName) {
+ if ($sanitizedFileName !== $fileName) {
throw new InvalidCharacterInPathException();
}
}
-
+
/**
* @param array $options
*/
@@ -525,6 +525,7 @@ abstract class Common implements Storage {
public function getMountOption($name, $default = null) {
return isset($this->mountOptions[$name]) ? $this->mountOptions[$name] : $default;
}
+
/**
* @param \OCP\Files\Storage $sourceStorage
* @param string $sourceInternalPath
@@ -533,6 +534,10 @@ abstract class Common implements Storage {
* @return bool
*/
public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) {
+ if ($sourceStorage === $this) {
+ return $this->copy($sourceInternalPath, $targetInternalPath);
+ }
+
if ($sourceStorage->is_dir($sourceInternalPath)) {
$dh = $sourceStorage->opendir($sourceInternalPath);
$result = $this->mkdir($targetInternalPath);
@@ -575,6 +580,10 @@ abstract class Common implements Storage {
* @return bool
*/
public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
+ if ($sourceStorage === $this) {
+ return $this->rename($sourceInternalPath, $targetInternalPath);
+ }
+
$result = $this->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, true);
if ($result) {
if ($sourceStorage->is_dir($sourceInternalPath)) {
diff --git a/lib/private/files/storage/wrapper/wrapper.php b/lib/private/files/storage/wrapper/wrapper.php
index f3dc09db138..14024addec4 100644
--- a/lib/private/files/storage/wrapper/wrapper.php
+++ b/lib/private/files/storage/wrapper/wrapper.php
@@ -513,6 +513,10 @@ class Wrapper implements \OC\Files\Storage\Storage {
* @return bool
*/
public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
+ if ($sourceStorage === $this) {
+ return $this->copy($sourceInternalPath, $targetInternalPath);
+ }
+
return $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
}
@@ -523,6 +527,10 @@ class Wrapper implements \OC\Files\Storage\Storage {
* @return bool
*/
public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
+ if ($sourceStorage === $this) {
+ return $this->rename($sourceInternalPath, $targetInternalPath);
+ }
+
return $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
}