Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2012-11-07 00:59:59 +0400
committerTom Needham <needham.thomas@gmail.com>2012-11-08 15:37:27 +0400
commit0833be9d4eacdfd712b9a52ab4545effb64f790a (patch)
tree72a3b2b7c0d1947955a1085d00402ba062464814 /lib/migrate.php
parentfbc3123d8e599ee5ae4a574856d93e4603aba843 (diff)
Migration: On import of user accounts only import folders in home dir, use OC_Helper::copyr
Check files when copying recursivley Remove obsolete method Dont count '.' and '..' as directories when importing.
Diffstat (limited to 'lib/migrate.php')
-rw-r--r--lib/migrate.php46
1 files changed, 12 insertions, 34 deletions
diff --git a/lib/migrate.php b/lib/migrate.php
index 96f5a0001f7..58b9182a45f 100644
--- a/lib/migrate.php
+++ b/lib/migrate.php
@@ -200,7 +200,7 @@ class OC_Migrate{
$scan = scandir( $extractpath );
// Check for export_info.json
if( !in_array( 'export_info.json', $scan ) ) {
- OC_Log::write( 'migration', 'Invalid import file, export_info.json note found', OC_Log::ERROR );
+ OC_Log::write( 'migration', 'Invalid import file, export_info.json not found', OC_Log::ERROR );
return json_encode( array( 'success' => false ) );
}
$json = json_decode( file_get_contents( $extractpath . 'export_info.json' ) );
@@ -235,8 +235,17 @@ class OC_Migrate{
return json_encode( array( 'success' => false ) );
}
// Copy data
- if( !self::copy_r( $extractpath . $json->exporteduser, $datadir . '/' . self::$uid ) ) {
- return json_encode( array( 'success' => false ) );
+ $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 ) );
+ }
}
// Import user app data
if( !$appsimported = self::importAppData( $extractpath . $json->exporteduser . '/migration.db', $json, self::$uid ) ) {
@@ -305,37 +314,6 @@ class OC_Migrate{
}
/**
- * @brief copies recursively
- * @param $path string path to source folder
- * @param $dest string path to destination
- * @return bool
- */
- private static function copy_r( $path, $dest ) {
- if( is_dir($path) ) {
- @mkdir( $dest );
- $objects = scandir( $path );
- if( sizeof( $objects ) > 0 ) {
- foreach( $objects as $file ) {
- if( $file == "." || $file == ".." || $file == ".htaccess")
- continue;
- // go on
- if( is_dir( $path . '/' . $file ) ) {
- self::copy_r( $path .'/' . $file, $dest . '/' . $file );
- } else {
- copy( $path . '/' . $file, $dest . '/' . $file );
- }
- }
- }
- return true;
- }
- elseif( is_file( $path ) ) {
- return copy( $path, $dest );
- } else {
- return false;
- }
- }
-
- /**
* @brief tries to extract the import zip
* @param $path string path to the zip
* @return string path to extract location (with a trailing slash) or false on failure