Merge branch 'm35_MDL-60923_New_BackupDir_Setting-v2' of https://github.com/scara/moodle

This commit is contained in:
Andrew Nicols 2018-04-17 09:44:44 +08:00
commit f8ad868fad
37 changed files with 170 additions and 83 deletions

View file

@ -442,6 +442,7 @@ if ($interactive) {
}
}
$CFG->tempdir = $CFG->dataroot.'/temp';
$CFG->backuptempdir = $CFG->tempdir.'/backup';
$CFG->cachedir = $CFG->dataroot.'/cache';
$CFG->localcachedir = $CFG->dataroot.'/localcache';

View file

@ -207,9 +207,9 @@ class category_bin extends base_bin {
// Get the backup file.
$file = reset($files);
// Get a temp directory name and create it.
// Get a backup temp directory name and create it.
$tempdir = \restore_controller::get_tempdir_name($context->id, $user->id);
$fulltempdir = make_temp_directory('/backup/' . $tempdir);
$fulltempdir = make_backup_temp_directory($tempdir);
// Extract the backup to tmpdir.
$fb = get_file_packer('application/vnd.moodle.backup');

View file

@ -211,9 +211,9 @@ class course_bin extends base_bin {
// Get the backup file.
$file = reset($files);
// Get a temp directory name and create it.
// Get a backup temp directory name and create it.
$tempdir = \restore_controller::get_tempdir_name($context->id, $user->id);
$fulltempdir = make_temp_directory('/backup/' . $tempdir);
$fulltempdir = make_backup_temp_directory($tempdir);
// Extract the backup to tempdir.
$fb = get_file_packer('application/vnd.moodle.backup');

View file

@ -347,7 +347,7 @@ class tool_uploadcourse_course {
/**
* Get the directory of the object to restore.
*
* @return string|false|null subdirectory in $CFG->tempdir/backup/..., false when an error occured
* @return string|false|null subdirectory in $CFG->backuptempdir/..., false when an error occured
* and null when there is simply nothing.
*/
protected function get_restore_content_dir() {

View file

@ -227,7 +227,7 @@ class tool_uploadcourse_helper {
}
// If we don't use the cache, or if we do and not set, or the directory doesn't exist any more.
if (!$usecache || (($backupid = $cache->get($cachekey)) === false || !is_dir("$CFG->tempdir/backup/$backupid"))) {
if (!$usecache || (($backupid = $cache->get($cachekey)) === false || !is_dir(get_backup_temp_directory($backupid)))) {
// Use null instead of false because it would consider that the cache key has not been set.
$backupid = null;
@ -236,7 +236,7 @@ class tool_uploadcourse_helper {
// Extracting the backup file.
$packer = get_file_packer('application/vnd.moodle.backup');
$backupid = restore_controller::get_tempdir_name(SITEID, $USER->id);
$path = "$CFG->tempdir/backup/$backupid/";
$path = make_backup_temp_directory($backupid, false);
$result = $packer->extract_to_pathname($backupfile, $path);
if (!$result) {
$errors['invalidbackupfile'] = new lang_string('invalidbackupfile', 'tool_uploadcourse');

View file

@ -259,7 +259,7 @@ class tool_uploadcourse_processor {
/**
* Get the directory of the object to restore.
*
* @return string subdirectory in $CFG->tempdir/backup/...
* @return string subdirectory in $CFG->backuptempdir/...
*/
protected function get_restore_content_dir() {
$backupfile = null;