diff options
author | Robin Appelman <icewind1991@gmail.com> | 2010-07-04 18:08:35 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2010-07-04 18:08:35 +0200 |
commit | d374bcddc10874c89afbd63311819adaad72bc17 (patch) | |
tree | 90669923e50f6b9f5fa6fc8b754a532a961c8258 | |
parent | baf7e00a943afbbb62f374b63d9d4280a5aa22d1 (diff) | |
download | nextcloud-server-d374bcddc10874c89afbd63311819adaad72bc17.tar.gz nextcloud-server-d374bcddc10874c89afbd63311819adaad72bc17.zip |
fix recursive copying of folders with webdav
-rwxr-xr-x | inc/HTTP/WebDAV/Server/Filesystem.php | 9 | ||||
-rwxr-xr-x[-rw-r--r--] | inc/lib_filestorage.php | 23 | ||||
-rwxr-xr-x | inc/lib_filesystem.php | 14 |
3 files changed, 39 insertions, 7 deletions
diff --git a/inc/HTTP/WebDAV/Server/Filesystem.php b/inc/HTTP/WebDAV/Server/Filesystem.php index 11e7630d797..72e747439d5 100755 --- a/inc/HTTP/WebDAV/Server/Filesystem.php +++ b/inc/HTTP/WebDAV/Server/Filesystem.php @@ -241,7 +241,6 @@ { // get absolute fs path to requested resource) $fspath = $options["path"]; - error_log("get $fspath"); // is this a collection? if (OC_FILESYSTEM::is_dir($fspath)) { return $this->GetDir($fspath, $options); @@ -358,7 +357,6 @@ $path = $options["path"]; $parent = dirname($path); $name = basename($path); - if (!OC_FILESYSTEM::file_exists($parent)) { return "409 Conflict"; } @@ -393,7 +391,6 @@ function DELETE($options) { $path =$options["path"]; - if (!OC_FILESYSTEM::file_exists($path)) { return "404 Not found"; } @@ -501,7 +498,7 @@ if ($del) { if (!OC_FILESYSTEM::rename($source, $dest)) { - return "500 Internal server error 1"; + return "500 Internal server error"; } $destpath = $this->_unslashify($options["dest"]); if (is_dir($source)) { @@ -517,8 +514,7 @@ OC_DB::query($query); } else { if (OC_FILESYSTEM::is_dir($source)) { - $files = OC_FILESYSTEM::find($source); - $files = array_reverse($files); + $files = OC_FILESYSTEM::getTree($source); } else { $files = array($source); } @@ -576,7 +572,6 @@ } else { if (isset($prop["val"])) { $query = "REPLACE INTO properties SET path = '$options[path]', name = '$prop[name]', ns= '$prop[ns]', value = '$prop[val]'"; - error_log($query); } else { $query = "DELETE FROM properties WHERE path = '$options[path]' AND name = '$prop[name]' AND ns = '$prop[ns]'"; } diff --git a/inc/lib_filestorage.php b/inc/lib_filestorage.php index 8448eddd74a..85382a44447 100644..100755 --- a/inc/lib_filestorage.php +++ b/inc/lib_filestorage.php @@ -72,6 +72,7 @@ class OC_FILESTORAGE{ public function getMimeType($path){} public function delTree($path){} public function find($path){} + public function getTree($path){} } /** @@ -364,5 +365,27 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{ } return $return; } + + public function getTree($dir) { + if(substr($dir,-1,1)=='/'){ + $dir=substr($dir,0,-1); + } + $tree=array(); + $tree[]=$dir; + $dirRelative=$dir; + $dir=$this->datadir.$dir; + if (!file_exists($dir)) return true; + foreach (scandir($dir) as $item) { + if ($item == '.' || $item == '..') continue; + if(is_file($dir.'/'.$item)){ + $tree[]=$dirRelative.'/'.$item; + }elseif(is_dir($dir.'/'.$item)){ + if ($subTree=$this->getTree($dirRelative. "/" . $item)){ + $tree=array_merge($tree,$subTree); + } + } + } + return $tree; + } } ?>
\ No newline at end of file diff --git a/inc/lib_filesystem.php b/inc/lib_filesystem.php index f441d55e7f8..6eb317f442e 100755 --- a/inc/lib_filesystem.php +++ b/inc/lib_filesystem.php @@ -278,5 +278,19 @@ class OC_FILESYSTEM{ } return $return; } + static public function getTree($path){ + if(self::canRead($path) and $storage=self::getStorage($path)){ + $mp=self::getMountPoint($path); + $return=$storage->getTree(substr($path,strlen($mp))); + echo "mp: $mp"; + foreach($return as &$file){ + if(substr($file,0,1)=='/'){ + $file=substr($file,1); + } + $file=$mp.$file; + } + return $return; + } + } } ?> |