]> source.dussan.org Git - nextcloud-server.git/commitdiff
better handeling of files that can behave like folder (e.g. archives)
authorRobin Appelman <icewind@owncloud.com>
Sat, 3 Mar 2012 17:02:07 +0000 (18:02 +0100)
committerRobin Appelman <icewind@owncloud.com>
Sat, 3 Mar 2012 20:23:35 +0000 (21:23 +0100)
files/index.php
lib/filecache.php
lib/filestorage/local.php
lib/filesystem.php
lib/filesystemview.php

index a29d3fb7e1e5a65ac9dc0788549a08120b5bfcbb..79261e495be0bbd77552ba263d7e467737adcc9c 100644 (file)
@@ -40,7 +40,7 @@ OC_App::setActiveNavigationEntry( "files_index" );
 // Load the files
 $dir = isset( $_GET['dir'] ) ? stripslashes($_GET['dir']) : '';
 // Redirect if directory does not exist
-if(!OC_Filesystem::is_dir($dir)) {
+if(!OC_Filesystem::is_dir($dir.'/')) {
        header("Location: ".$_SERVER['PHP_SELF']."");
 }
 
index 732160c216a02f9a7a5ee8927aceb2babef2927d..e94ae49c73ac044da0ff3030051ef3bac8773b50 100644 (file)
@@ -323,10 +323,11 @@ class OC_FileCache{
                $path=$params['path'];
                $fullPath=$view->getRoot().$path;
                $mimetype=$view->getMimeType($path);
+               $dir=$view->is_dir($path.'/');
                //dont use self::get here, we don't want inifinte loops when a file has changed
                $cachedSize=self::getCachedSize($path,$root);
                $size=0;
-               if($mimetype=='httpd/unix-directory'){
+               if($dir){
                        if(self::inCache($path,$root)){
                                $parent=self::getFileId($fullPath);
                                $query=OC_DB::prepare('SELECT size FROM *PREFIX*fscache WHERE parent=?');
@@ -465,13 +466,13 @@ class OC_FileCache{
                        $view=new OC_FilesystemView(($root=='/')?'':$root);
                }
                self::scanFile($path,$root);
-               $dh=$view->opendir($path);
+               $dh=$view->opendir($path.'/');
                $totalSize=0;
                if($dh){
                        while (($filename = readdir($dh)) !== false) {
                                if($filename != '.' and $filename != '..'){
                                        $file=$path.'/'.$filename;
-                                       if($view->is_dir($file)){
+                                       if($view->is_dir($file.'/')){
                                                if($eventSource){
                                                        $eventSource->send('scanning',array('file'=>$file,'count'=>$count));
                                                }
index 8e07ce6025b88904674d235bd67273ad6de2826e..750a1fb36ddb8e895c2eb5e6f537508bddf11dab 100644 (file)
@@ -21,7 +21,7 @@ class OC_Filestorage_Local extends OC_Filestorage{
                return opendir($this->datadir.$path);
        }
        public function is_dir($path){
-               return (is_dir($this->datadir.$path) or substr($path,-1)=='/');
+               return @is_dir($this->datadir.$path);
        }
        public function is_file($path){
                return is_file($this->datadir.$path);
index 5013b3968c5a9c8088463bf02a9f2d2ee931e121..12905d189f947c2e878466695df9cd6b3e886cfb 100644 (file)
@@ -146,20 +146,15 @@ class OC_Filesystem{
        * @return string
        */
        static public function getMountPoint($path){
+               OC_Hook::emit(self::CLASSNAME,'get_mountpoint',array('path'=>$path));
                if(!$path){
                        $path='/';
                }
                if(substr($path,0,1)!=='/'){
                        $path='/'.$path;
                }
-               if(substr($path,-1)!=='/'){
-                       $path=$path.'/';
-               }
                $foundMountPoint='';
                foreach(OC_Filesystem::$mounts as $mountpoint=>$storage){
-                       if(substr($mountpoint,-1)!=='/'){
-                               $mountpoint=$mountpoint.'/';
-                       }
                        if($mountpoint==$path){
                                return $mountpoint;
                        }
@@ -259,6 +254,9 @@ class OC_Filesystem{
        * @param string mountpoint
        */
        static public function mount($class,$arguments,$mountpoint){
+               if(substr($mountpoint,-1)!=='/'){
+                       $mountpoint=$mountpoint.'/';
+               }
                if(substr($mountpoint,0,1)!=='/'){
                        $mountpoint='/'.$mountpoint;
                }
index 2d54a676c8c4fa0181b781fe961c92ca237bce87..89e0385fe9c6247ba6879200f34fff309df4a69b 100644 (file)
@@ -205,6 +205,7 @@ class OC_FilesystemView {
                                        $count=OC_Helper::streamCopy($data,$target);
                                        $storage1=$this->getStorage($path1);
                                        $storage1->unlink($this->getInternalPath($path1));
+                                       $result=$count>0;
                                }
                                OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_rename, array( OC_Filesystem::signal_param_oldpath => $path1, OC_Filesystem::signal_param_newpath=>$path2));
                                return $result;