]> source.dussan.org Git - nextcloud-server.git/commitdiff
allow tear down of filesystem.
authorRobin Appelman <icewind1991@gmail.com>
Sat, 11 Jun 2011 22:57:43 +0000 (00:57 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Sat, 11 Jun 2011 22:57:43 +0000 (00:57 +0200)
also fix a bug when chrooting to '/'

lib/base.php
lib/filesystem.php

index a3ffb6b1a6fe0e43682c45dcc30756e9e96452fd..50c41dc0859758a7bfdad8c56b96e24b5675ddd6 100644 (file)
@@ -145,7 +145,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 and the backupstorage if needed
-                       $rootStorage=OC_FILESYSTEM::createStorage('local',array('datadir'=>$CONFIG_DATADIRECTORY));
+                       $rootStorage=OC_FILESYSTEM::createStorage('local',array('datadir'=>$CONFIG_DATADIRECTORY_ROOT));
 //                     if( OC_CONFIG::getValue( "enablebackup", false )){
 //                             // This creates the Directorys recursively
 //                             if(!is_dir( "$CONFIG_BACKUPDIRECTORY/$user/$root" )){
@@ -182,6 +182,11 @@ class OC_UTIL {
                }
        }
 
+       public static function tearDownFS(){
+               OC_FILESYSTEM::tearDown();
+               self::$fsSetup=false;
+       }
+
        /**
         * get the current installed version of ownCloud
         * @return array
index 2b5c3a56b6e3e90574649e8286fef6e484fad4f5..27a937f5e4c778491d6aade5b1cfe3996336117a 100644 (file)
@@ -67,6 +67,16 @@ class OC_FILESYSTEM{
                return array_keys(self::$storageTypes);
        }
        
+       /**
+        * tear down the filesystem, removing all storage providers
+        */
+       static public function tearDown(){
+               foreach(self::$storages as $mountpoint=>$storage){
+                       unset(self::$storages[$mountpoint]);
+               }
+               $fakeRoot='';
+       }
+       
        /**
        * create a new storage of a specific type
        * @param  string  type
@@ -91,8 +101,10 @@ class OC_FILESYSTEM{
        * @return bool
        */
        static public function chroot($fakeRoot){
-               if($fakeRoot[0]!=='/'){
-                       $fakeRoot='/'.$fakeRoot;
+               if(!$fakeRoot==''){
+                       if($fakeRoot[0]!=='/'){
+                               $fakeRoot='/'.$fakeRoot;
+                       }
                }
                self::$fakeRoot=$fakeRoot;
        }