diff options
author | Tom Needham <needham.thomas@gmail.com> | 2012-03-13 17:27:47 +0000 |
---|---|---|
committer | Tom Needham <needham.thomas@gmail.com> | 2012-03-13 17:27:47 +0000 |
commit | cd2f75fdad6629f850bb07f07cd45e04d75de97d (patch) | |
tree | e2403eff902510e24ab0c7539d96e7ca9038e849 | |
parent | 0f3eebbbd95b75e3dfe8f9322d8fd486925ac54a (diff) | |
download | nextcloud-server-cd2f75fdad6629f850bb07f07cd45e04d75de97d.tar.gz nextcloud-server-cd2f75fdad6629f850bb07f07cd45e04d75de97d.zip |
Use data dir from config.php
-rw-r--r-- | apps/admin_export/settings.php | 4 | ||||
-rw-r--r-- | apps/user_migrate/settings.php | 22 | ||||
-rw-r--r-- | lib/migrate.php | 5 |
3 files changed, 10 insertions, 21 deletions
diff --git a/apps/admin_export/settings.php b/apps/admin_export/settings.php index b60557f3503..73a4209d3f8 100644 --- a/apps/admin_export/settings.php +++ b/apps/admin_export/settings.php @@ -31,6 +31,7 @@ define('DS', '/'); if (isset($_POST['admin_export'])) { $root = OC::$SERVERROOT . "/"; + $datadir = OC_Config::getValue( 'datadirectory' ); $zip = new ZipArchive(); $tempdir = get_temp_dir(); $filename = $tempdir . "/owncloud_export_" . date("y-m-d_H-i-s") . ".zip"; @@ -70,7 +71,6 @@ if (isset($_POST['admin_export'])) { OC_Log::write('admin_export',"Adding owncloud config to export",OC_Log::INFO); zipAddDir($root . "config/", $zip, true, "/"); - $zip->addFile($root . '/data/.htaccess', "data/owncloud.db"); } if (isset($_POST['user_files'])) { @@ -80,7 +80,7 @@ if (isset($_POST['admin_export'])) { $zip->addFile($root . '/data/index.html', "data/index.html"); foreach (OC_User::getUsers() as $i) { OC_Log::write('admin_export',"Adding owncloud user files of $i to export",OC_Log::INFO); - zipAddDir($root . "data/" . $i, $zip, true, "/data/"); + zipAddDir($datadir . '/' . $i, $zip, true, "/data/"); } } diff --git a/apps/user_migrate/settings.php b/apps/user_migrate/settings.php index c017ba226cf..5e8ac9c21df 100644 --- a/apps/user_migrate/settings.php +++ b/apps/user_migrate/settings.php @@ -32,20 +32,9 @@ if (isset($_POST['user_export'])) { $zip = new ZipArchive(); $tmp = get_temp_dir(); $user = OC_User::getUser(); - // Create owncoud dir - if( !file_exists( $tmp . '/owncloud' ) ){ - if( !mkdir( $tmp . '/owncloud' ) ){ - die('Failed to create the owncloud tmp directory'); - } - } - // Create the export dir - $exportdir = $tmp . '/owncloud' . '/export_' . $user . '_' . date("y-m-d_H-i-s"); - if( !file_exists( $exportdir ) ){ - if( !mkdir( $exportdir ) ){ - die('Failed to create the owncloud export directory'); - } - } - $filename = $exportdir . '/owncloud_export_' . $user . '_' . date("y-m-d_H-i-s") . ".zip"; + + $userdatadir = OC_Config::getValue( 'datadirectory' ) . '/' . $user; + $filename = $userdatadir . '/owncloud_export_' . $user . '_' . date("y-m-d_H-i-s") . ".zip"; OC_Log::write('user_migrate',"Creating export file at: " . $filename,OC_Log::INFO); if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) { exit("Cannot open <$filename>\n"); @@ -53,11 +42,11 @@ if (isset($_POST['user_export'])) { // Migrate the app info $info = json_encode( OC_Migrate::export( $user ) ); - $infofile = OC::$SERVERROOT . '/data/' . $user . '/exportinfo.json'; + $infofile = $userdatadir . '/exportinfo.json'; file_put_contents( $infofile, $info ); // Add the data dir (which includes migration.db and exportinfo.json) - zipAddDir(OC::$SERVERROOT . "/data/" . $user, $zip, true, "/"); + zipAddDir( $userdatadir, $zip, true, "/" ); // Save the zip $zip->close(); @@ -70,7 +59,6 @@ if (isset($_POST['user_export'])) { readfile($filename); // Cleanup unlink($filename); - rmdir($exportdir); OC_Migrate::cleanUp(); } if( isset( $_POST['user_import'] ) ){ diff --git a/lib/migrate.php b/lib/migrate.php index 1be229d8fdd..a6a6432d0de 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -447,10 +447,11 @@ class OC_Migrate{ OC_Log::write('migration', 'Failed to cleanup after migration', OC_Log::ERROR); return false; } + $userdatadir = OC_Config::getValue( 'datadirectory' ) . '/' . self::$uid; // Remove migration.db - unlink( OC::$SERVERROOT . '/data/' . self::$uid . '/migration.db' ); + unlink( $userdatadir . '/migration.db' ); // Remove exportinfo.json - unlink( OC::$SERVERROOT . '/data/' . self::$uid . '/exportinfo.json' ); + unlink( $userdatadir . '/exportinfo.json' ); return true; } } |