all repos — searchix @ 495994761bc04fd9b46e65e389e8b2cda28f1020

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

refactor: use options struct for all arguments to index constructor

Alan Pearce
commit

495994761bc04fd9b46e65e389e8b2cda28f1020

parent

450ff2d51460c2f1e8b0679726d3a26cd8762359

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

changed files
M internal/index/indexer.gointernal/index/indexer.go
@@ -34,9 +34,11 @@
var idAnalyzer analysis.Analyzer type Options struct { + Force bool LowMemory bool BatchSize int Logger *log.Logger + Root *file.Root } type WriteIndex struct {
@@ -223,13 +225,12 @@ return nil
} func OpenOrCreate( - root *file.Root, - force bool, options *Options, ) (*ReadIndex, *WriteIndex, bool, error) { var err error bleve.SetLog(zap.NewStdLog(options.Logger.Named("bleve").GetLogger())) + root := options.Root exists, err := root.Exists(indexBaseName) if err != nil { return nil, nil, exists, fault.Wrap(
@@ -238,8 +239,8 @@ }
var idx bleve.Index var meta *Meta - if !exists || force { - if force { + if !exists || options.Force { + if options.Force { err = deleteIndex(root) if err != nil { return nil, nil, false, err