all repos — searchix @ 3b877b39b424ded0f776d1dc71d07616a47bfbd4

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

fix: store only data from current entity in index
Alan Pearce alan@alanpearce.eu
Fri, 17 May 2024 17:02:00 +0200
commit

3b877b39b424ded0f776d1dc71d07616a47bfbd4

parent

041ebd2291db60e73d7fc213cd8a74d33b7f089b

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

jump to
M internal/importer/options.gointernal/importer/options.go
@@ -120,7 +120,6 @@ x := kv.Value.(map[string]interface{}) 
 			var decls []*nix.Link
 			for _, decl := range x["declarations"].([]interface{}) {
-				i.optJSON = nixOptionJSON{}
 
 				switch decl := reflect.ValueOf(decl); decl.Kind() {
 				case reflect.String:
@@ -152,6 +151,7 @@ if len(decls) > 0 { 				x["declarations"] = decls
 			}
 
+			i.optJSON = nixOptionJSON{}
 			err := i.ms.Decode(x) // stores in optJSON
 			if err != nil {
 				errs <- errors.WithMessagef(err, "failed to decode option %#v", x)
M internal/importer/package.gointernal/importer/package.go
@@ -39,7 +39,7 @@ type PackageIngester struct {
 	dec    *jstream.Decoder
 	ms     *mapstructure.Decoder
-	pkg    *packageJSON
+	pkg    packageJSON
 	infile io.ReadCloser
 	source *config.Source
 }
@@ -62,14 +62,14 @@ func NewPackageProcessor(infile io.ReadCloser, source *config.Source) (*PackageIngester, error) {
 	i := &PackageIngester{
 		dec:    jstream.NewDecoder(infile, 2).EmitKV(),
-		pkg:    &packageJSON{},
+		pkg:    packageJSON{},
 		infile: infile,
 		source: source,
 	}
 
 	ms, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
 		ZeroFields: true,
-		Result:     i.pkg,
+		Result:     &i.pkg,
 		Squash:     true,
 		DecodeHook: mapstructure.TextUnmarshallerHookFunc(),
 	})
@@ -203,6 +203,7 @@ ) 				}
 			}
 
+			i.pkg = packageJSON{}
 			err = i.ms.Decode(x) // stores in i.pkg
 			if err != nil {
 				errs <- errors.WithMessagef(err, "failed to decode package %#v", x)