refactor: use options struct for all arguments to index constructor
1 file changed, 5 insertions(+), 4 deletions(-)
changed files
M internal/index/indexer.go → internal/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