all repos — searchix @ e6651469b9e934cb4dc65f760277111a79e9ae2d

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

fix: create index metadata when index exists and meta doesn't
Alan Pearce alan@alanpearce.eu
Sat, 08 Jun 2024 21:18:39 +0200
commit

e6651469b9e934cb4dc65f760277111a79e9ae2d

parent

d0c47991981a706973899ad2c29c550a22ea6bb8

1 files changed, 8 insertions(+), 0 deletions(-)

jump to
M internal/index/index_meta.gointernal/index/index_meta.go
@@ -46,6 +46,14 @@ }, nil }
 
 func openMeta(path string) (*Meta, error) {
+	exists, err := file.Exists(path)
+	if err != nil {
+		return nil, errors.WithMessage(err, "could not check for existence of index metadata")
+	}
+	if !exists {
+		return createMeta(path)
+	}
+
 	j, err := os.ReadFile(path)
 	if err != nil {
 		return nil, errors.WithMessage(err, "could not open index metadata file")