function _backup_migrate_temp_files_delete in Backup and Migrate 7.2
Same name and namespace in other branches
- 8.2 includes/files.inc \_backup_migrate_temp_files_delete()
- 8.3 includes/files.inc \_backup_migrate_temp_files_delete()
- 5.2 includes/files.inc \_backup_migrate_temp_files_delete()
- 5 backup_migrate.module \_backup_migrate_temp_files_delete()
- 6.3 includes/files.inc \_backup_migrate_temp_files_delete()
- 6 backup_migrate.module \_backup_migrate_temp_files_delete()
- 6.2 includes/files.inc \_backup_migrate_temp_files_delete()
- 7.3 includes/files.inc \_backup_migrate_temp_files_delete()
Delete all temporary files.
2 calls to _backup_migrate_temp_files_delete()
- backup_migrate_cleanup in ./
backup_migrate.module - Cleanup after a success or failure.
- backup_migrate_cron in ./
backup_migrate.module - Implementation of hook_cron().
1 string reference to '_backup_migrate_temp_files_delete'
- backup_migrate_cleanup in ./
backup_migrate.module - Cleanup after a success or failure.
File
- includes/
files.inc, line 27 - General file handling code for Backup and Migrate.
Code
function _backup_migrate_temp_files_delete() {
// Delete the temp files created during this run.
foreach (backup_migrate_temp_files_add() as $file) {
$file = drupal_realpath($file);
if (file_exists($file) && is_writable($file)) {
unlink($file);
}
}
// Delete temp files abandoned for 6 or more hours.
$dir = file_stream_wrapper_get_instance_by_scheme('temporary')
->getDirectoryPath();
$expire = time() - variable_get('backup_migrate_cleanup_time', 21600);
if (file_exists($dir) && is_dir($dir) && is_readable($dir) && ($handle = opendir($dir))) {
while (FALSE !== ($file = @readdir($handle))) {
// Delete 'backup_migrate_' files in the temp directory that are older than the expire time.
// We should only attempt to delete writable files to prevent errors in shared environments.
// This could still cause issues in shared environments with poorly configured file permissions.
if (strpos($file, 'backup_migrate_') === 0 && is_writable("{$dir}/{$file}") && @filectime("{$dir}/{$file}") < $expire) {
unlink("{$dir}/{$file}");
}
}
closedir($handle);
}
}