]> source.dussan.org Git - nextcloud-server.git/commitdiff
try to use transactions to replace db
authorTom Needham <needham.thomas@gmail.com>
Sun, 1 Apr 2012 00:25:47 +0000 (00:25 +0000)
committerTom Needham <needham.thomas@gmail.com>
Sun, 1 Apr 2012 00:25:47 +0000 (00:25 +0000)
apps/admin_export/settings.php
lib/db.php
lib/migrate.php

index 269147a3bc642b1f667e50d46fa48935037578ed..719bedb66e8459ff9fb4de0844a917adbf94fece 100644 (file)
@@ -28,7 +28,7 @@ OC_Util::checkAppEnabled('admin_export');
 // Export?
 if (isset($_POST['admin_export'])) {
        // Create the export zip
-       if( !$path = OC_Migrate::export( $_POST['export_type'] ) ){
+       if( !$path = OC_Migrate::export( null, $_POST['export_type'] ) ){
                // Error
                die('error');   
        } else {
index a7b7ae75da0fc69639091052ff85b5848d0e43f8..9c46a40addbd95450d029a663fbe999bdee71f3d 100644 (file)
@@ -489,7 +489,7 @@ class OC_DB {
         public static function replaceDB( $file ){
                
                $apps = OC_App::getAllApps();
-               
+               self::beginTransaction();
                // Delete the old tables
                self::removeDBStructure( OC::$SERVERROOT . '/db_structure.xml' );
                
@@ -501,11 +501,8 @@ class OC_DB {
                }
                
                // Create new tables
-               if( self::createDBFromStructure( $file ) ){
-                       return true;
-               } else {
-                       return false;   
-               }
+               self::createDBFromStructure( $file );
+               self::commit();
                
         }
        
index db3852fb8323d24a4e7cdf7d4e587cfe53ec9e76..815333b4d890aa2b91ac412e39645b504af3ff26 100644 (file)
@@ -257,28 +257,30 @@ class OC_Migrate{
                                return $appsimported;
                        break;
                        case 'instance':
+                                       /*
                                        // Check for new data dir and dbexport before doing anything
                                        // TODO
-                                       /*
+                                       
                                        // Delete current data folder.
                                        OC_Log::write( 'migration', "Deleting current data dir", OC_Log::INFO );
-                                       if( self::unlink_r( $datadir, false ) ){
+                                       if( !self::unlink_r( $datadir, false ) ){
                                                OC_Log::write( 'migration', 'Failed to delete the current data dir', OC_Log::ERROR );
                                                return false;   
                                        }
                                
                                        // Copy over data
-                                       if( !self::copy_r( $extractname . 'data', $datadir ) ){
+                                       if( !self::copy_r( $extractpath . 'userdata', $datadir ) ){
                                                OC_Log::write( 'migration', 'Failed to copy over data directory', OC_Log::ERROR );
                                                return false;   
                                        }
-                                       */
+                                       
                                        // Import the db
                                        if( !OC_DB::replaceDB( $extractpath . 'dbexport.xml' ) ){
                                                return false;   
                                        }
                                        // Done
                                        return true; 
+                                       */
                        break;  
                }