about summary refs log tree commit diff stats
path: root/internal/index
diff options
context:
space:
mode:
authorAlan Pearce2024-06-08 21:18:39 +0200
committerAlan Pearce2024-06-08 21:18:39 +0200
commite6651469b9e934cb4dc65f760277111a79e9ae2d (patch)
tree30ee025c3af768c9ec582fa2f11a2a34e063c5f9 /internal/index
parentd0c47991981a706973899ad2c29c550a22ea6bb8 (diff)
downloadsearchix-e6651469b9e934cb4dc65f760277111a79e9ae2d.tar.lz
searchix-e6651469b9e934cb4dc65f760277111a79e9ae2d.tar.zst
searchix-e6651469b9e934cb4dc65f760277111a79e9ae2d.zip
fix: create index metadata when index exists and meta doesn't
Diffstat (limited to 'internal/index')
-rw-r--r--internal/index/index_meta.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/index/index_meta.go b/internal/index/index_meta.go
index f28abc4..47aa858 100644
--- a/internal/index/index_meta.go
+++ b/internal/index/index_meta.go
@@ -46,6 +46,14 @@ func createMeta(path string) (*Meta, error) {
 }
 
 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")