| 817 | use super::*; |
| 818 | |
| 819 | pub(super) async fn run(watcher: GitWatcher, global_db_path: Option<PathBuf>) { |
| 820 | let interval_mins = watcher.inner.config.backstop_interval_mins; |
| 821 | if interval_mins == 0 { |
| 822 | return; // disabled |
| 823 | } |
| 824 | let period = Duration::from_secs(interval_mins.saturating_mul(60).max(1)); |
| 825 | let mut ticker = tokio::time::interval(period); |
| 826 | // Skip the immediate first tick so startup registration settles first. |
| 827 | ticker.tick().await; |
| 828 | |
| 829 | let mut last_gc: Option<Instant> = None; |
| 830 | let gc_period = Duration::from_hours(24); |
| 831 | |
| 832 | loop { |
| 833 | ticker.tick().await; |
| 834 | tick(&watcher, global_db_path.as_deref(), &mut last_gc, gc_period).await; |
| 835 | } |
| 836 | } |
| 837 | |
| 838 | async fn tick( |
| 839 | watcher: &GitWatcher, |