From: Tom Needham Date: Sun, 1 Apr 2012 00:25:47 +0000 (+0000) Subject: try to use transactions to replace db X-Git-Tag: v4.0.0beta~386 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=eba6a65908ab848741a29467a2c054818e3c740c;p=nextcloud-server.git try to use transactions to replace db --- diff --git a/apps/admin_export/settings.php b/apps/admin_export/settings.php index 269147a3bc6..719bedb66e8 100644 --- a/apps/admin_export/settings.php +++ b/apps/admin_export/settings.php @@ -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 { diff --git a/lib/db.php b/lib/db.php index a7b7ae75da0..9c46a40addb 100644 --- a/lib/db.php +++ b/lib/db.php @@ -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(); } diff --git a/lib/migrate.php b/lib/migrate.php index db3852fb832..815333b4d89 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -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; }