remove the need to register storage providers, pass the classname during mounting instead

This commit is contained in:
Robin Appelman 2011-11-08 22:21:25 +01:00
parent 878fc1d197
commit ec015a2e68
5 changed files with 9 additions and 46 deletions

View File

@ -5,7 +5,6 @@ require_once('apps/files_sharing/sharedstorage.php');
OC::$CLASSPATH['OC_Share'] = "apps/files_sharing/lib_share.php";
OC_Hook::connect("OC_Filesystem", "post_delete", "OC_Share", "deleteItem");
OC_Hook::connect("OC_Filesystem", "post_rename", "OC_Share", "renameItem");
OC_Filesystem::registerStorageType("shared", "OC_Filestorage_Shared", array("datadir" => "string"));
OC_Util::addScript("files_sharing", "share");
OC_Util::addScript("3rdparty", "chosen/chosen.jquery.min");
OC_Util::addStyle( 'files_sharing', 'sharing' );

View File

@ -25,7 +25,7 @@ require_once( 'lib_share.php' );
if (!OC_Filesystem::is_dir('/Shared')) {
OC_Filesystem::mkdir('/Shared');
}
OC_Filesystem::mount('shared',array('datadir'=>'/'.OC_User::getUser().'/files/Shared'),'/'.OC_User::getUser().'/files/Shared/');
OC_Filesystem::mount('OC_Filestorage_Shared',array('datadir'=>'/'.OC_User::getUser().'/files/Shared'),'/'.OC_User::getUser().'/files/Shared/');
/**
* Convert target path to source path and pass the function call to the correct storage provider

View File

@ -157,9 +157,6 @@ class OC{
OC_User::useBackend( OC_Config::getValue( "userbackend", "database" ));
OC_Group::setBackend( OC_Config::getValue( "groupbackend", "database" ));
// Was in required file ... put it here
OC_Filesystem::registerStorageType('local','OC_Filestorage_Local',array('datadir'=>'string'));
// Set up file system unless forbidden
global $RUNTIME_NOSETUPFS;
if(!$RUNTIME_NOSETUPFS ){

View File

@ -46,35 +46,6 @@ class OC_Filesystem{
static private $storages=array();
static private $mounts=array();
static private $fakeRoot='';
static private $storageTypes=array();
/**
* register a storage type
* @param string type
* @param string classname
* @param array arguments an associative array in the form of name=>type (eg array('datadir'=>'string'))
*/
static public function registerStorageType($type,$classname,$arguments){
self::$storageTypes[$type]=array('type'=>$type,'classname'=>$classname,'arguments'=>$arguments);
}
/**
* check if the filesystem supports a specific storagetype
* @param string type
* @return bool
*/
static public function hasStorageType($type){
return isset(self::$storageTypes[$type]);
}
/**
* get the list of names of storagetypes that the filesystem supports
* @return array
*/
static public function getStorageTypeNames(){
return array_keys(self::$storageTypes);
}
/**
* tear down the filesystem, removing all storage providers
@ -92,13 +63,9 @@ class OC_Filesystem{
* @param array arguments
* @return OC_Filestorage
*/
static private function createStorage($type,$arguments){
if(!self::hasStorageType($type)){
return false;
}
$className=self::$storageTypes[$type]['classname'];
if(class_exists($className)){
return new $className($arguments);
static private function createStorage($class,$arguments){
if(class_exists($class)){
return new $class($arguments);
}else{
return false;
}
@ -164,11 +131,11 @@ class OC_Filesystem{
* @param OC_Filestorage storage
* @param string mountpoint
*/
static public function mount($type,$arguments,$mountpoint){
static public function mount($class,$arguments,$mountpoint){
if(substr($mountpoint,0,1)!=='/'){
$mountpoint='/'.$mountpoint;
}
self::$mounts[$mountpoint]=array('type'=>$type,'arguments'=>$arguments);
self::$mounts[$mountpoint]=array('class'=>$class,'arguments'=>$arguments);
}
/**
@ -181,7 +148,7 @@ class OC_Filesystem{
if($mountpoint){
if(!isset(self::$storages[$mountpoint])){
$mount=self::$mounts[$mountpoint];
self::$storages[$mountpoint]=self::createStorage($mount['type'],$mount['arguments']);
self::$storages[$mountpoint]=self::createStorage($mount['class'],$mount['arguments']);
}
return self::$storages[$mountpoint];
}
@ -285,7 +252,7 @@ class OC_Filesystem{
return self::basicOperation('filemtime',$path);
}
static public function fileatime($path){
return self::basicOperation('fileatime',$path);
return self::basicOperation('filemtime',$path);
}
static public function file_get_contents($path){
return self::basicOperation('file_get_contents',$path,array('read'));

View File

@ -37,7 +37,7 @@ class OC_Util {
if( $user != "" ){ //if we aren't logged in, there is no use to set up the filesystem
//first set up the local "root" storage
OC_Filesystem::mount('local',array('datadir'=>$CONFIG_DATADIRECTORY_ROOT),'/');
OC_Filesystem::mount('OC_Filestorage_Local',array('datadir'=>$CONFIG_DATADIRECTORY_ROOT),'/');
OC::$CONFIG_DATADIRECTORY = $CONFIG_DATADIRECTORY_ROOT."/$user/$root";
if( !is_dir( OC::$CONFIG_DATADIRECTORY )){