]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix issue with moving music files
authorRobin Appelman <icewind@owncloud.com>
Sat, 14 Jan 2012 20:13:46 +0000 (21:13 +0100)
committerRobin Appelman <icewind@owncloud.com>
Sat, 14 Jan 2012 20:13:46 +0000 (21:13 +0100)
lib/files.php

index 88b559059f00570ec065d5901970432e933a5a56..9ae5320ad1dfbde46c5e76c26e1ded16d7f17a86 100644 (file)
@@ -183,8 +183,8 @@ class OC_Files {
        */
        public static function move($sourceDir,$source,$targetDir,$target){
                if(OC_User::isLoggedIn()){
-                       $targetFile=$targetDir.'/'.$target;
-                       $sourceFile=$sourceDir.'/'.$source;
+                       $targetFile=self::normalizePath($targetDir.'/'.$target);
+                       $sourceFile=self::normalizePath($sourceDir.'/'.$source);
                        return OC_Filesystem::rename($sourceFile,$targetFile);
                }
        }
@@ -305,4 +305,19 @@ class OC_Files {
                $content.= "Options -Indexes\n";
                @file_put_contents(OC::$SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
        }
+
+       /**
+        * normalize a path, removing any double, add leading /, etc
+        * @param string $path
+        * @return string
+        */
+       static public function normalizePath($path){
+               $path='/'.$path;
+               $old='';
+               while($old!=$path){//replace any multiplicity of slashes with a single one
+                       $old=$path;
+                       $path=str_replace('//','/',$path);
+               }
+               return $path;
+       }
 }