Index: includes/files.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/backup_migrate/includes/Attic/files.inc,v retrieving revision 1.1.2.1.2.2 diff -u -r1.1.2.1.2.2 files.inc --- includes/files.inc 29 Sep 2008 03:56:05 -0000 1.1.2.1.2.2 +++ includes/files.inc 16 Jan 2009 00:29:34 -0000 @@ -47,6 +47,14 @@ } /** + * Implementation of hook_exit(). + */ +function backup_migrate_exit() { + // Delete any temporary files generated during this execution. + backup_migrate_temp_file('', TRUE); +} + +/** * Decompress a file with the given settings. * Also updates settings to reflect new file mime and file extension. */ @@ -135,8 +143,11 @@ return; } else { - $file = tempnam(file_directory_temp(), 'tmp_'); - $file .= $extension ? ".". $extension : ""; + $file = tempnam(file_directory_temp(), 'backup_migrate_'); + if (!empty($extension)) { + unlink($file); + $file .= '.'. $extension; + } $files[] = $file; return $file; } Index: backup_migrate.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/backup_migrate/backup_migrate.module,v retrieving revision 1.1.2.25.2.1.2.6 diff -u -r1.1.2.25.2.1.2.6 backup_migrate.module --- backup_migrate.module 29 Sep 2008 03:56:05 -0000 1.1.2.25.2.1.2.6 +++ backup_migrate.module 16 Jan 2009 00:29:34 -0000 @@ -239,13 +239,20 @@ } /** - * Implementation of hook_cron(), + * Implementation of hook_cron(). * - * Takes care of scheduled backups. + * Takes care of scheduled backups and deletes abandoned temp files. */ function backup_migrate_cron() { require_once './'. drupal_get_path('module', 'backup_migrate') .'/includes/schedules.inc'; backup_migrate_schedules_run(); + + // Delete temp files abandoned for 6 or more hours. + foreach (file_scan_directory(file_directory_temp(), 'backup_migrate_*', array('.', '..'), 0, FALSE) as $file) { + if (filectime($file->filename) < time() - 21600) { + unlink($file->filename); + } + } } /**