all repos — searchix @ 001c5b4f4e6dcf0110504211d3f1298d5e6abc48

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

feat: add --fetch action to populate data/sources

Alan Pearce
commit

001c5b4f4e6dcf0110504211d3f1298d5e6abc48

parent

a49d405f81ed9b872ae638832f3a1a5f2339780c

1 file changed, 9 insertions(+), 4 deletions(-)

changed files
M internal/importer/main.gointernal/importer/main.go
@@ -62,6 +62,7 @@ func (imp *Importer) createSourceImporter(
parent context.Context, meta *index.Meta, forceUpdate bool, + fetchOnly bool, ) func(*config.Source) error { return func(source *config.Source) error { logger := imp.options.Logger.With("name", source.Key)
@@ -105,16 +106,18 @@ }
logger.Info( "importer fetch succeeded", "previous", - previousUpdate, + previousUpdate.Format(time.DateTime), "current", sourceMeta.Updated.Format(time.DateTime), "is_updated", sourceMeta.Updated.After(previousUpdate), "update_force", forceUpdate, + "fetch_only", + fetchOnly, ) - if sourceMeta.Updated.After(previousUpdate) || forceUpdate { + if !fetchOnly && (!sourceMeta.Updated.After(previousUpdate) || forceUpdate) { var pdb *programs.DB if source.Programs.Enable {
@@ -191,6 +194,7 @@
func (imp *Importer) Start( ctx context.Context, forceUpdate bool, + fetchOnly bool, onlyUpdateSources *[]string, ) error { if len(imp.config.Importer.Sources) == 0 {
@@ -210,7 +214,7 @@ forceUpdate = forceUpdate || (onlyUpdateSources != nil && len(*onlyUpdateSources) > 0)
meta := imp.options.WriteIndex.Meta - importSource := imp.createSourceImporter(importCtx, meta, forceUpdate) + importSource := imp.createSourceImporter(importCtx, meta, forceUpdate, fetchOnly) for name, source := range imp.config.Importer.Sources { if onlyUpdateSources != nil && len(*onlyUpdateSources) > 0 { if !slices.Contains(*onlyUpdateSources, name) {
@@ -267,6 +271,7 @@ imp.options.Logger.Info("adding new sources", "sources", newSources)
err := imp.Start( ctx, false, + false, &newSources, ) if err != nil {
@@ -337,7 +342,7 @@ }, monitorConfig)
MarkIndexingStarted() ctx, cancel := context.WithTimeout(parentCtx, imp.config.Importer.Timeout.Duration) - err = imp.Start(ctx, false, nil) + err = imp.Start(ctx, false, false, nil) cancel() if err != nil {