diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-07-01 18:02:56 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-05-28 18:16:23 +0200 |
commit | c3c9612c99c0bd8b2da9cac262045c43775f2988 (patch) | |
tree | 8fc71b8055e75e71ab2e8919fbdb7471e102dbd1 | |
parent | 03ba497a8c1e149857d6c3a4d4cab49dea5903c1 (diff) | |
download | nextcloud-server-c3c9612c99c0bd8b2da9cac262045c43775f2988.tar.gz nextcloud-server-c3c9612c99c0bd8b2da9cac262045c43775f2988.zip |
fix recursive copy and rename for mapped local storage backend
-rw-r--r-- | lib/private/files/storage/mappedlocal.php | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/lib/private/files/storage/mappedlocal.php b/lib/private/files/storage/mappedlocal.php index 07691661644..9d3fa01d883 100644 --- a/lib/private/files/storage/mappedlocal.php +++ b/lib/private/files/storage/mappedlocal.php @@ -177,6 +177,12 @@ class MappedLocal extends \OC\Files\Storage\Common{ return false; } + if ($this->is_dir($path2)) { + $this->rmdir($path2); + } else if ($this->is_file($path2)) { + $this->unlink($path2); + } + $physicPath1 = $this->buildPath($path1); $physicPath2 = $this->buildPath($path2); if($return=rename($physicPath1, $physicPath2)) { @@ -187,18 +193,29 @@ class MappedLocal extends \OC\Files\Storage\Common{ return $return; } public function copy($path1, $path2) { - if($this->is_dir($path2)) { - if(!$this->file_exists($path2)) { - $this->mkdir($path2); + if ($this->is_dir($path1)) { + if ($this->is_dir($path2)) { + $this->rmdir($path2); + } else if ($this->is_file($path2)) { + $this->unlink($path2); } - $source=substr($path1, strrpos($path1, '/')+1); - $path2.=$source; - } - if($return=copy($this->buildPath($path1), $this->buildPath($path2))) { - // mapper needs to create copies or all children - $this->copyMapping($path1, $path2); + $dir = $this->opendir($path1); + $this->mkdir($path2); + while ($file = readdir($dir)) { + if (($file != '.') && ($file != '..')) { + if (!$this->copy($path1 . '/' . $file, $path2 . '/' . $file)) { + return false; + } + } + } + closedir($dir); + return true; + } else { + if ($return = copy($this->buildPath($path1), $this->buildPath($path2))) { + $this->copyMapping($path1, $path2); + } + return $return; } - return $return; } public function fopen($path, $mode) { if($return=fopen($this->buildPath($path), $mode)) { |