mirror of
https://github.com/moodle/moodle.git
synced 2025-03-20 07:30:01 +01:00
MDL-60923 scheduled tasks: stale temp files in $CFG->backuptempdir too
This commit is contained in:
parent
ef844148a9
commit
40d90f438a
@ -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…
x
Reference in New Issue
Block a user