From ec015a2e6806be90516e5cba009823050d98bcb0 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 8 Nov 2011 22:21:25 +0100 Subject: [PATCH] remove the need to register storage providers, pass the classname during mounting instead --- apps/files_sharing/appinfo/app.php | 1 - apps/files_sharing/sharedstorage.php | 2 +- lib/base.php | 3 -- lib/filesystem.php | 47 +++++----------------------- lib/util.php | 2 +- 5 files changed, 9 insertions(+), 46 deletions(-) diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php index c175142319..a675175a8b 100644 --- a/apps/files_sharing/appinfo/app.php +++ b/apps/files_sharing/appinfo/app.php @@ -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' ); diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php index faf4e68d9b..5ab976aaf4 100644 --- a/apps/files_sharing/sharedstorage.php +++ b/apps/files_sharing/sharedstorage.php @@ -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 diff --git a/lib/base.php b/lib/base.php index c52b4493e0..2d0bb5fb25 100644 --- a/lib/base.php +++ b/lib/base.php @@ -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 ){ diff --git a/lib/filesystem.php b/lib/filesystem.php index cae8ead5b1..e28a3c5667 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -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')); diff --git a/lib/util.php b/lib/util.php index 14313569a1..e010a572e3 100644 --- a/lib/util.php +++ b/lib/util.php @@ -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 )){