]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix recursive copying of folders with webdav
authorRobin Appelman <icewind1991@gmail.com>
Sun, 4 Jul 2010 16:08:35 +0000 (18:08 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Sun, 4 Jul 2010 16:08:35 +0000 (18:08 +0200)
inc/HTTP/WebDAV/Server/Filesystem.php
inc/lib_filestorage.php [changed mode: 0644->0755]
inc/lib_filesystem.php

index 11e7630d797bf5427eebcbb82df267c62f1986cc..72e747439d53aca037672b966aa389d6c90da782 100755 (executable)
     {
         // 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);
         $path   = $options["path"];
         $parent = dirname($path);
         $name   = basename($path);
-               
         if (!OC_FILESYSTEM::file_exists($parent)) {
             return "409 Conflict";
         }
     function DELETE($options) 
     {
         $path =$options["path"];
-
         if (!OC_FILESYSTEM::file_exists($path)) {
             return "404 Not found";
         }
 
         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)) {
                 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);
             }
             } 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]'";
                 }       
old mode 100644 (file)
new mode 100755 (executable)
index 8448edd..85382a4
@@ -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
index f441d55e7f8d895f5c12476348cdf84324794d20..6eb317f442e223a3979148e696e041b6147d66e4 100755 (executable)
@@ -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;
+               }
+       }
 }
 ?>