try to use transactions to replace db
This commit is contained in:
parent
ffbd72bbcf
commit
eba6a65908
3 changed files with 10 additions and 11 deletions
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue