all repos — searchix @ d558039919b6198a246a6a3fd007276191cb4b2f

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

fix: rebuild index when --replace is specified
Alan Pearce alan@alanpearce.eu
Thu, 16 May 2024 21:00:35 +0200
commit

d558039919b6198a246a6a3fd007276191cb4b2f

parent

9b430ab18dc024058ea9c039fb64af0a3d5e3529

2 files changed, 5 insertions(+), 5 deletions(-)

jump to
M internal/index/indexer.gointernal/index/indexer.go
@@ -182,22 +182,22 @@ if !exists || force { 		if force {
 			err = deleteIndex(dataRoot)
 			if err != nil {
-				return nil, nil, exists, err
+				return nil, nil, false, err
 			}
 		}
 		idx, err = createIndex(indexPath)
 		if err != nil {
-			return nil, nil, exists, err
+			return nil, nil, false, err
 		}
 
 		meta, err = createMeta(metaPath)
 		if err != nil {
-			return nil, nil, exists, err
+			return nil, nil, false, err
 		}
 
 		err = meta.Save()
 		if err != nil {
-			return nil, nil, exists, err
+			return nil, nil, false, err
 		}
 	} else {
 		idx, err = bleve.Open(indexPath)
M searchix.gosearchix.go
@@ -81,7 +81,7 @@ if err != nil { 		log.Fatalf("Failed to open or create index: %v", err)
 	}
 
-	if !exists {
+	if !exists || *replace {
 		slog.Info("Index doesn't exist. Starting build job...")
 		err = importer.Start(cfg, write, *replace)
 		if err != nil {