diff options
Diffstat (limited to 'lib/private/files/storage/common.php')
-rw-r--r-- | lib/private/files/storage/common.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index fc30b385e2e..1257a14dd04 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -274,6 +274,8 @@ abstract class Common implements Storage { /** * @param string $query + * @param string $dir + * @return array */ protected function searchInDir($query, $dir = '') { $files = array(); @@ -498,18 +500,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 +527,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 +536,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 +582,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)) { |