diff options
author | Alan Pearce | 2025-03-24 17:18:49 +0100 |
---|---|---|
committer | Alan Pearce | 2025-03-24 17:18:49 +0100 |
commit | 6984d4d32ab506494394f8a6a8aa18041c45b9e8 (patch) | |
tree | 1f180c74239c547d46f2eb83abefd5312a44e871 | |
parent | 41d40588457290477d87346a133be72be6c621cb (diff) | |
download | searchix-6984d4d32ab506494394f8a6a8aa18041c45b9e8.tar.lz searchix-6984d4d32ab506494394f8a6a8aa18041c45b9e8.tar.zst searchix-6984d4d32ab506494394f8a6a8aa18041c45b9e8.zip |
feat: re-index on startup if last run > 24 hours ago
-rw-r--r-- | internal/importer/main.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/internal/importer/main.go b/internal/importer/main.go index 5b48007..184c6df 100644 --- a/internal/importer/main.go +++ b/internal/importer/main.go @@ -300,7 +300,13 @@ func (imp *Importer) StartUpdateTimer( Timezone: time.Local.String(), } - nextRun := nextUTCOccurrenceOfTime(imp.config.Importer.UpdateAt) + var nextRun time.Time + if Job.FinishedAt.Before(time.Now().Add(-24 * time.Hour)) { + imp.log.Info("indexing last ran more than 24 hours ago, scheduling immediate update") + nextRun = time.Now() + } else { + nextRun = nextUTCOccurrenceOfTime(imp.config.Importer.UpdateAt) + } SetNextRun(nextRun) for { imp.log.Debug("scheduling next run", "next-run", nextRun) @@ -338,7 +344,7 @@ func (imp *Importer) StartUpdateTimer( Status: sentry.CheckInStatusOK, }, monitorConfig) } - nextRun = nextRun.AddDate(0, 0, 1) + nextRun = nextUTCOccurrenceOfTime(imp.config.Importer.UpdateAt) MarkIndexingFinished(nextRun) } }) |