Use data dir from config.php

This commit is contained in:
Tom Needham 2012-03-13 17:27:47 +00:00
parent 0f3eebbbd9
commit cd2f75fdad
3 changed files with 10 additions and 21 deletions

View file

@ -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/");
}
}

View file

@ -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'] ) ){

View file

@ -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;
}
}