Skip to content

Commit

Permalink
Migration: Allow for no app data cases; handle file copying better
Browse files Browse the repository at this point in the history
  • Loading branch information
tomneedham committed Nov 8, 2012
1 parent e8a0cea commit 4619c66
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,16 @@ public static function import( $path, $type='user', $uid=null ) {
$userfolder = $extractpath . $json->exporteduser;
$newuserfolder = $datadir . '/' . self::$uid;
foreach(scandir($userfolder) as $file){
$success = true;
if($file !== '.' && $file !== '..' && is_dir($file)){
// Then copy the folder over
$success = OC_Helper::copyr($userfolder.'/'.$file, $newuserfolder.'/'.$file);
}
if(!$success){
return json_encode( array( 'success' => false ) );
OC_Helper::copyr($userfolder.'/'.$file, $newuserfolder.'/'.$file);
}
}
// Import user app data
if( !$appsimported = self::importAppData( $extractpath . $json->exporteduser . '/migration.db', $json, self::$uid ) ) {
return json_encode( array( 'success' => false ) );
if(file_exists($extractpath . $json->exporteduser . '/migration.db')){
if( !$appsimported = self::importAppData( $extractpath . $json->exporteduser . '/migration.db', $json, self::$uid ) ) {
return json_encode( array( 'success' => false ) );
}
}
// All done!
if( !self::unlink_r( $extractpath ) ) {
Expand Down

0 comments on commit 4619c66

Please sign in to comment.