From 60b924c954ac880f5d17ce91f733850c5b010e0f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 25 Apr 2012 00:08:45 +0200 Subject: initial mount configuration work --- lib/filesystem.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'lib/filesystem.php') diff --git a/lib/filesystem.php b/lib/filesystem.php index dc678fba74c..1b91eabc7c1 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -196,9 +196,57 @@ class OC_Filesystem{ return false; } self::$defaultInstance=new OC_FilesystemView($root); + + //load custom mount config + if(is_file(OC::$SERVERROOT.'/config/mount.php')){ + $mountConfig=include(OC::$SERVERROOT.'/config/mount.php'); + if(isset($mountConfig['global'])){ + foreach($mountConfig['global'] as $mountPoint=>$options){ + self::mount($options['class'],$options['options'],$mountPoint); + } + } + + if(isset($mountConfig['group'])){ + foreach($mountConfig['group'] as $group=>$mounts){ + if(OC_Group::inGroup(OC_User::getUser(),$group)){ + foreach($mounts as $mountPoint=>$options){ + $mountPoint=self::setUserVars($mountPoint); + foreach($options as &$option){ + $option=self::setUserVars($option); + } + self::mount($options['class'],$options['options'],$mountPoint); + } + } + } + } + + if(isset($mountConfig['user'])){ + foreach($mountConfig['user'] as $user=>$mounts){ + if($user==='all' or strtolower($user)===strtolower(OC_User::getUser())){ + foreach($mounts as $mountPoint=>$options){ + $mountPoint=self::setUserVars($mountPoint); + foreach($options as &$option){ + $option=self::setUserVars($option); + } + self::mount($options['class'],$options['options'],$mountPoint); + } + } + } + } + } + self::$loaded=true; } + /** + * fill in the correct values for $user, and $password placeholders + * @param string intput + * @return string + */ + private static function setUserVars($input){ + return str_replace('$user',OC_User::getUser(),$input); + } + /** * get the default filesystem view * @return OC_FilesystemView -- cgit v1.2.3 From e3adbcb7d58d06c2bac8d925930d2deb2ed563ea Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 29 Apr 2012 15:09:47 +0200 Subject: remove non existing files from the cache when rescanning a folder --- lib/filecache.php | 34 +++++++++++++++++++--------------- lib/filesystem.php | 1 + 2 files changed, 20 insertions(+), 15 deletions(-) (limited to 'lib/filesystem.php') diff --git a/lib/filecache.php b/lib/filecache.php index 28a9eb247a6..431470696a6 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -522,26 +522,30 @@ class OC_FileCache{ $view=new OC_FilesystemView(($root=='/')?'':$root); } self::scanFile($path,$root); - $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.'/')){ - self::scan($file,$eventSource,$count,$root); - }else{ - $totalSize+=self::scanFile($file,$root); - $count++; - if($count>$lastSend+25 and $eventSource){ - $lastSend=$count; - $eventSource->send('scanning',array('file'=>$path,'count'=>$count)); + if(self::inCache($path)){ + self::updateFolder($path,$root); + }else{ + $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.'/')){ + self::scan($file,$eventSource,$count,$root); + }else{ + $totalSize+=self::scanFile($file,$root); + $count++; + if($count>$lastSend+25 and $eventSource){ + $lastSend=$count; + $eventSource->send('scanning',array('file'=>$path,'count'=>$count)); + } } } } } + self::increaseSize($view->getRoot().$path,$totalSize); } - self::increaseSize($view->getRoot().$path,$totalSize); } /** diff --git a/lib/filesystem.php b/lib/filesystem.php index 1b91eabc7c1..cac7e8648ef 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -275,6 +275,7 @@ class OC_Filesystem{ if(class_exists($class)){ return new $class($arguments); }else{ + OC_Log::write('core','storage backend '.$class.' not found',OC_Log::ERROR); return false; } } -- cgit v1.2.3