try to use transactions to replace db

This commit is contained in:
Tom Needham 2012-04-01 00:25:47 +00:00
parent ffbd72bbcf
commit eba6a65908
3 changed files with 10 additions and 11 deletions

View File

@ -28,7 +28,7 @@ OC_Util::checkAppEnabled('admin_export');
// Export? // Export?
if (isset($_POST['admin_export'])) { if (isset($_POST['admin_export'])) {
// Create the export zip // Create the export zip
if( !$path = OC_Migrate::export( $_POST['export_type'] ) ){ if( !$path = OC_Migrate::export( null, $_POST['export_type'] ) ){
// Error // Error
die('error'); die('error');
} else { } else {

View File

@ -489,7 +489,7 @@ class OC_DB {
public static function replaceDB( $file ){ public static function replaceDB( $file ){
$apps = OC_App::getAllApps(); $apps = OC_App::getAllApps();
self::beginTransaction();
// Delete the old tables // Delete the old tables
self::removeDBStructure( OC::$SERVERROOT . '/db_structure.xml' ); self::removeDBStructure( OC::$SERVERROOT . '/db_structure.xml' );
@ -501,11 +501,8 @@ class OC_DB {
} }
// Create new tables // Create new tables
if( self::createDBFromStructure( $file ) ){ self::createDBFromStructure( $file );
return true; self::commit();
} else {
return false;
}
} }

View File

@ -257,28 +257,30 @@ class OC_Migrate{
return $appsimported; return $appsimported;
break; break;
case 'instance': case 'instance':
/*
// Check for new data dir and dbexport before doing anything // Check for new data dir and dbexport before doing anything
// TODO // TODO
/*
// Delete current data folder. // Delete current data folder.
OC_Log::write( 'migration', "Deleting current data dir", OC_Log::INFO ); 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 ); OC_Log::write( 'migration', 'Failed to delete the current data dir', OC_Log::ERROR );
return false; return false;
} }
// Copy over data // 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 ); OC_Log::write( 'migration', 'Failed to copy over data directory', OC_Log::ERROR );
return false; return false;
} }
*/
// Import the db // Import the db
if( !OC_DB::replaceDB( $extractpath . 'dbexport.xml' ) ){ if( !OC_DB::replaceDB( $extractpath . 'dbexport.xml' ) ){
return false; return false;
} }
// Done // Done
return true; return true;
*/
break; break;
} }