Commit e02c9b26 authored by Nigel McNie's avatar Nigel McNie
Browse files

(#3414) Clean up old exports and imports from disk.



Turns out exports were already done, though I got the cronjob time
wrong. The import cronjob was a simple addition.
Signed-off-by: default avatarNigel McNie <nigel@catalyst.net.nz>
parent c4ec434b
......@@ -302,5 +302,24 @@ class MnetImporterTransport extends ImporterTransport {
}
}
/**
* Looks in the import staging area in dataroot and deletes old, unneeded
* import.
*/
function import_cleanup_old_imports() {
require_once('file.php');
$basedir = get_config('dataroot') . 'import/';
$importdir = new DirectoryIterator($basedir);
$mintime = time() - (12 * 60 * 60); // delete imports older than 12 hours
// The import dir contains one directory for each attempted import, named
// after their username and the import timestamp
foreach ($importdir as $attemptdir) {
if ($attemptdir->isDot()) continue;
if ($attemptdir->getCTime() < $mintime) {
rmdirr($basedir . $attemptdir->getFilename());
}
}
}
?>
......@@ -1260,6 +1260,21 @@ function xmldb_core_upgrade($oldversion=0) {
set_config('creategroups', 'all');
}
if ($oldversion < 2009110900) {
// Fix export cronjob so it runs 12 hours apart
execute_sql("UPDATE {cron} SET hour = '3,15' WHERE callfunction = 'export_cleanup_old_exports'");
// Cron job to clean old imports
$cron = new StdClass;
$cron->callfunction = 'import_cleanup_old_imports';
$cron->minute = '0';
$cron->hour = '4,16';
$cron->day = '*';
$cron->month = '*';
$cron->dayofweek = '*';
insert_record('cron', $cron);
}
return $status;
}
......
......@@ -768,7 +768,8 @@ function core_install_firstcoredata_defaults() {
'recalculate_quota' => array('15', '2', '*', '*', '*'),
'import_process_queue' => array('*/5', '*', '*', '*', '*'),
'cron_send_registration_data' => array(rand(0, 59), rand(0, 23), '*', '*', rand(0, 6)),
'export_cleanup_old_exports' => array('0', '3,13', '*', '*', '*'),
'export_cleanup_old_exports' => array('0', '3,15', '*', '*', '*'),
'import_cleanup_old_imports' => array('0', '4,16', '*', '*', '*'),
);
foreach ($cronjobs as $callfunction => $times) {
$cron = new StdClass;
......
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2009110500;
$config->version = 2009110900;
$config->release = '1.2.0beta5dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment