summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2012-03-27 21:21:14 +0000
committerTom Needham <needham.thomas@gmail.com>2012-03-27 21:21:14 +0000
commitef33219e4f83652676c7a668b6126c3c1c0da34d (patch)
treea246aedbefe5d7b31492bb171db35d1bab1a2379
parent31d268fe929abefbbf14e76a96c02f18235451a8 (diff)
downloadnextcloud-server-ef33219e4f83652676c7a668b6126c3c1c0da34d.tar.gz
nextcloud-server-ef33219e4f83652676c7a668b6126c3c1c0da34d.zip
import method returns each apps' import status
-rw-r--r--apps/user_migrate/admin.php16
-rw-r--r--lib/migrate.php40
-rw-r--r--lib/migration/provider.php2
3 files changed, 42 insertions, 16 deletions
diff --git a/apps/user_migrate/admin.php b/apps/user_migrate/admin.php
index c1afb0aed4f..1c4894c0f22 100644
--- a/apps/user_migrate/admin.php
+++ b/apps/user_migrate/admin.php
@@ -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.' );
}
diff --git a/lib/migrate.php b/lib/migrate.php
index d7d1400e2fa..b16b84b2a4b 100644
--- a/lib/migrate.php
+++ b/lib/migrate.php
@@ -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;
}
diff --git a/lib/migration/provider.php b/lib/migration/provider.php
index 98804ee91c9..feae29f1354 100644
--- a/lib/migration/provider.php
+++ b/lib/migration/provider.php
@@ -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;
}
/**