[Pkg-owncloud-commits] [owncloud] 95/199: fix recursive copy and rename for mapped local storage backend

David Prévot taffit at moszumanska.debian.org
Sun Jun 1 18:53:13 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit c3c9612c99c0bd8b2da9cac262045c43775f2988
Author: Robin Appelman <icewind at owncloud.com>
Date:   Mon Jul 1 18:02:56 2013 +0200

    fix recursive copy and rename for mapped local storage backend
---
 lib/private/files/storage/mappedlocal.php | 37 ++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/lib/private/files/storage/mappedlocal.php b/lib/private/files/storage/mappedlocal.php
index 0769166..9d3fa01 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)) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list