protected function backup_migrate_schedule::find_nearest_file in Backup and Migrate 7.3
1 call to backup_migrate_schedule::find_nearest_file()
- backup_migrate_schedule::smart_delete_backups in includes/
schedules.inc - Delete files keeping the specified number of hourly, daily, weekly and monthly backups.
File
- includes/
schedules.inc, line 872 - All of the schedule handling code needed for Backup and Migrate.
Class
- backup_migrate_schedule
- A schedule class for crud operations.
Code
protected function find_nearest_file($files, $time) {
$last_file_id = NULL;
$last_file_time = NULL;
foreach ($files as $id => $file_time) {
if ($file_time >= $time) {
if ($last_file_time == NULL) {
return $id;
}
if ($file_time == $time) {
return $id;
}
$time_to_prev = $time - $last_file_time;
$time_to_next = $file_time - $time;
if ($time_to_prev >= $time_to_next) {
return $id;
}
else {
return $last_file_id;
}
// Shouldn't hit this but you never know.
break;
}
$last_file_id = $id;
$last_file_time = $file_time;
}
}