From e6651469b9e934cb4dc65f760277111a79e9ae2d Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 8 Jun 2024 21:18:39 +0200 Subject: fix: create index metadata when index exists and meta doesn't --- internal/index/index_meta.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'internal/index') 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") -- cgit 1.4.1