mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
import method returns each apps' import status
This commit is contained in:
parent
31d268fe92
commit
ef33219e4f
3 changed files with 42 additions and 16 deletions
|
|
@ -40,8 +40,22 @@ if (isset($_POST['user_import'])) {
|
|||
exit();
|
||||
}
|
||||
|
||||
if( !OC_Migrate::import( $to, 'user' ) ){
|
||||
if( !$appsstatus = OC_Migrate::import( $to, 'user' ) ){
|
||||
die( 'failed to to import' );
|
||||
} else {
|
||||
// Check import status
|
||||
foreach( $appsstatus as $app => $status ){
|
||||
if( $status != 'true' ){
|
||||
// It failed for some reason
|
||||
if( $status == 'notsupported' ){
|
||||
$notsupported[] = $app;
|
||||
} else if( !$status ){
|
||||
$failed[] = $app;
|
||||
}
|
||||
}
|
||||
}
|
||||
die(print_r($notsupported));
|
||||
die( 'Some apps failed to import, or were not supported.' );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -246,14 +246,14 @@ class OC_Migrate{
|
|||
return false;
|
||||
}
|
||||
// Import user app data
|
||||
if( !self::importAppData( $extractpath . $json->exporteduser . '/migration.db', $json, self::$uid ) ){
|
||||
if( !$appsimported = self::importAppData( $extractpath . $json->exporteduser . '/migration.db', $json, self::$uid ) ){
|
||||
return false;
|
||||
}
|
||||
// All done!
|
||||
if( !self::unlink_r( $extractpath ) ){
|
||||
OC_Log::write( 'migration', 'Failed to delete the extracted zip', OC_Log::ERROR );
|
||||
}
|
||||
return true;
|
||||
return $appsimported;
|
||||
break;
|
||||
case 'instance':
|
||||
// Check for new data dir and dbexport before doing anything
|
||||
|
|
@ -611,9 +611,9 @@ class OC_Migrate{
|
|||
/**
|
||||
* @breif imports a new user
|
||||
* @param $db string path to migration.db
|
||||
* @param $info array of migration ino
|
||||
* @param $info object of migration info
|
||||
* @param $uid optional uid to use
|
||||
* @return bool if the import succedded
|
||||
* @return array of apps with import statuses, or false on failure.
|
||||
*/
|
||||
public static function importAppData( $db, $info, $uid=null ){
|
||||
// Check if the db exists
|
||||
|
|
@ -641,21 +641,33 @@ class OC_Migrate{
|
|||
// Is the app in the export?
|
||||
$id = $provider->getID();
|
||||
if( isset( $info->apps->$id ) ){
|
||||
// Did it succeed?
|
||||
if( $info->apps->$id->success ){
|
||||
// Give the provider the content object
|
||||
if( !self::connectDB( $db ) ){
|
||||
return false;
|
||||
// Is the app installed
|
||||
if( !OC_App::isEnabled( $id ) ){
|
||||
OC_Log::write( 'migration', 'App: ' . $id . ' is not installed, can\'t import data.', OC_Log::INFO );
|
||||
$appsstatus[$id] = 'notsupported';
|
||||
} else {
|
||||
// Did it succeed on export?
|
||||
if( $info->apps->$id->success ){
|
||||
// Give the provider the content object
|
||||
if( !self::connectDB( $db ) ){
|
||||
return false;
|
||||
}
|
||||
$content = new OC_Migration_Content( self::$zip, self::$MDB2 );
|
||||
$provider->setData( self::$uid, $content, $info );
|
||||
// Then do the import
|
||||
if( !$appsstatus[$id] = $provider->import( $info->apps->$id, $importinfo ) ){
|
||||
// Failed to import app
|
||||
OC_Log::write( 'migration', 'Failed to import app data for user: ' . self::$uid . ' for app: ' . $id, OC_Log::ERROR );
|
||||
}
|
||||
} else {
|
||||
// Add to failed list
|
||||
$appsstatus[$id] = false;
|
||||
}
|
||||
$content = new OC_Migration_Content( self::$zip, self::$MDB2 );
|
||||
$provider->setData( self::$uid, $content, $info );
|
||||
// Then do the import
|
||||
$provider->import( $info->apps->$id, $importinfo );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return $appsstatus;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ abstract class OC_Migration_Provider{
|
|||
public function setData( $uid, $content, $info=null ){
|
||||
$this->content = $content;
|
||||
$this->uid = $uid;
|
||||
$id = $this->id;
|
||||
if( !is_null( $info ) ){
|
||||
$this->olduid = $info->exporteduser;
|
||||
$this->appinfo = $info->apps->$id;
|
||||
}
|
||||
$id = $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue