mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 01:46:45 +02:00
Merge branch 'm35_MDL-60923_New_BackupDir_Setting-v2' of https://github.com/scara/moodle
This commit is contained in:
commit
f8ad868fad
37 changed files with 170 additions and 83 deletions
|
@ -375,9 +375,9 @@ class publication {
|
|||
global $CFG, $USER;
|
||||
require_once($CFG->libdir . "/filelib.php");
|
||||
|
||||
make_temp_directory('backup');
|
||||
$backuptempdir = make_backup_temp_directory('');
|
||||
$filename = md5(time() . '-' . $hubcourseid . '-'. $USER->id . '-'. random_string(20));
|
||||
$path = $CFG->tempdir.'/backup/'.$filename.".mbz";
|
||||
$path = $backuptempdir.'/'.$filename.".mbz";
|
||||
|
||||
api::download_course_backup($hubcourseid, $path);
|
||||
|
||||
|
|
|
@ -38,13 +38,13 @@ class file_temp_cleanup_task extends scheduled_task {
|
|||
}
|
||||
|
||||
/**
|
||||
* Do the job.
|
||||
* Throw exceptions on errors (the job will be retried).
|
||||
* Do the job, given the target directory.
|
||||
*
|
||||
* @param string $tmpdir The directory hosting the candidate stale temp files.
|
||||
*/
|
||||
public function execute() {
|
||||
protected function execute_on($tmpdir) {
|
||||
global $CFG;
|
||||
|
||||
$tmpdir = $CFG->tempdir;
|
||||
// Default to last weeks time.
|
||||
$time = time() - ($CFG->tempdatafoldercleanup * 3600);
|
||||
|
||||
|
@ -96,4 +96,23 @@ class file_temp_cleanup_task extends scheduled_task {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the job.
|
||||
* Throw exceptions on errors (the job will be retried).
|
||||
*/
|
||||
public function execute() {
|
||||
global $CFG;
|
||||
|
||||
// The directories hosting the candidate stale temp files eventually are $CFG->tempdir and $CFG->backuptempdir.
|
||||
|
||||
// Do the job on each of the directories above.
|
||||
// Let's start with $CFG->tempdir.
|
||||
$this->execute_on($CFG->tempdir);
|
||||
|
||||
// Run on $CFG->backuptempdir too, if different from the default one, '$CFG->tempdir/backup'.
|
||||
if (realpath(dirname($CFG->backuptempdir)) !== $CFG->tempdir) {
|
||||
// The $CFG->backuptempdir setting is different from the default '$CFG->tempdir/backup'.
|
||||
$this->execute_on($CFG->backuptempdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue