@@ -200,7 +200,7 @@ public static function import( $path, $type='user', $uid=null ) {
200200 $ scan = scandir ( $ extractpath );
201201 // Check for export_info.json
202202 if ( !in_array ( 'export_info.json ' , $ scan ) ) {
203- OC_Log::write ( 'migration ' , 'Invalid import file, export_info.json note found ' , OC_Log::ERROR );
203+ OC_Log::write ( 'migration ' , 'Invalid import file, export_info.json not found ' , OC_Log::ERROR );
204204 return json_encode ( array ( 'success ' => false ) );
205205 }
206206 $ json = json_decode ( file_get_contents ( $ extractpath . 'export_info.json ' ) );
@@ -235,8 +235,17 @@ public static function import( $path, $type='user', $uid=null ) {
235235 return json_encode ( array ( 'success ' => false ) );
236236 }
237237 // Copy data
238- if ( !self ::copy_r ( $ extractpath . $ json ->exporteduser , $ datadir . '/ ' . self ::$ uid ) ) {
239- return json_encode ( array ( 'success ' => false ) );
238+ $ userfolder = $ extractpath . $ json ->exporteduser ;
239+ $ newuserfolder = $ datadir . '/ ' . self ::$ uid ;
240+ foreach (scandir ($ userfolder ) as $ file ){
241+ $ success = true ;
242+ if ($ file !== '. ' && $ file !== '.. ' && is_dir ($ file )){
243+ // Then copy the folder over
244+ $ success = OC_Helper::copyr ($ userfolder .'/ ' .$ file , $ newuserfolder .'/ ' .$ file );
245+ }
246+ if (!$ success ){
247+ return json_encode ( array ( 'success ' => false ) );
248+ }
240249 }
241250 // Import user app data
242251 if ( !$ appsimported = self ::importAppData ( $ extractpath . $ json ->exporteduser . '/migration.db ' , $ json , self ::$ uid ) ) {
@@ -304,37 +313,6 @@ private static function unlink_r( $dir, $deleteRootToo=true ) {
304313 return true ;
305314 }
306315
307- /**
308- * @brief copies recursively
309- * @param $path string path to source folder
310- * @param $dest string path to destination
311- * @return bool
312- */
313- private static function copy_r ( $ path , $ dest ) {
314- if ( is_dir ($ path ) ) {
315- @mkdir ( $ dest );
316- $ objects = scandir ( $ path );
317- if ( sizeof ( $ objects ) > 0 ) {
318- foreach ( $ objects as $ file ) {
319- if ( $ file == ". " || $ file == ".. " || $ file == ".htaccess " )
320- continue ;
321- // go on
322- if ( is_dir ( $ path . '/ ' . $ file ) ) {
323- self ::copy_r ( $ path .'/ ' . $ file , $ dest . '/ ' . $ file );
324- } else {
325- copy ( $ path . '/ ' . $ file , $ dest . '/ ' . $ file );
326- }
327- }
328- }
329- return true ;
330- }
331- elseif ( is_file ( $ path ) ) {
332- return copy ( $ path , $ dest );
333- } else {
334- return false ;
335- }
336- }
337-
338316 /**
339317 * @brief tries to extract the import zip
340318 * @param $path string path to the zip
0 commit comments