all repos — searchix @ d8581c5d9b41485c6be7cdb61cdfca4ba323e593

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: don't block startup for indexing

Alan Pearce
commit

d8581c5d9b41485c6be7cdb61cdfca4ba323e593

parent

04dac54c8ab1b87af202b8d4af18c24d63240f0a

1 file changed, 10 insertions(+), 0 deletions(-)

changed files
M internal/importer/job.gointernal/importer/job.go
@@ -40,12 +40,22 @@ parentCtx context.Context,
) { var nextRun time.Time switch { + case !imp.options.WriteIndex.Exists(): + imp.options.Logger.Info( + "no index found, starting immediate update", + ) + nextRun = time.Now() case Job.LastRun.FinishedAt.Before(time.Now().Add(-24 * time.Hour)): imp.options.Logger.Info( "indexing last ran more than 24 hours ago, scheduling immediate update", ) nextRun = time.Now() default: + err := imp.EnsureSourcesIndexed(parentCtx, imp.options.ReadIndex) + if err != nil { + imp.options.Logger.Error("could not add new sources", "error", err) + } + nextRun = nextUTCOccurrenceOfTime(imp.config.Importer.UpdateAt) } SetNextRun(nextRun)