]> source.dussan.org Git - nextcloud-server.git/commitdiff
normalize the path once in upload.php is enough - THX Robin for this hint
authorThomas Mueller <thomas.mueller@tmit.eu>
Fri, 16 Nov 2012 10:50:57 +0000 (11:50 +0100)
committerThomas Mueller <thomas.mueller@tmit.eu>
Fri, 16 Nov 2012 10:50:57 +0000 (11:50 +0100)
apps/files/ajax/upload.php
lib/filecache.php

index 92871059936fb64cd9719a09a7aadded4c6f73d9..c3d3199a003eb087b039a42225fc4f29156484b4 100644 (file)
@@ -48,15 +48,11 @@ if(strpos($dir, '..') === false) {
        $fileCount=count($files['name']);
        for($i=0;$i<$fileCount;$i++) {
         $target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
+               // $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
+               $target = OC_Filesystem::normalizePath($target);
                if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
                        $meta = OC_FileCache::get($target);
                        $id = OC_FileCache::getId($target);
-                       // in case the upload goes to a sub directory getID() returns -1 and $target needs to be normalized
-                       // calling normalizePath() inside getId() causes endless scan.
-                       if ($id == -1) {
-                               $path = OC_Filesystem::normalizePath($target);
-                               $id = OC_FileCache::getId($path);
-                       }
                        $result[]=array( "status" => "success", 'mime'=>$meta['mimetype'], 'size'=>$meta['size'], 'id'=>$id, 'name'=>basename($target));
                }
        }
index 2a389dfc3ca85ddad778b0f286d97e172a41837b..4a7dbd0250d68ad1f9ab30eed8c75933588e3f36 100644 (file)
@@ -43,8 +43,6 @@ class OC_FileCache{
         * - versioned
         */
        public static function get($path, $root=false) {
-               // $path needs to be normalized - this failed within drag'n'drop upload to a subfolder
-               $path = OC_Filesystem::normalizePath($path);
                if(OC_FileCache_Update::hasUpdated($path, $root)) {
                        if($root===false) {//filesystem hooks are only valid for the default root
                                OC_Hook::emit('OC_Filesystem', 'post_write', array('path'=>$path));