all repos — searchix @ 12a29a55fe895a964d8d317857ee7fb87d4071f1

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

fix: always re-index if storage is (re-)created

Alan Pearce
commit

12a29a55fe895a964d8d317857ee7fb87d4071f1

parent

15a5b3210a073c83dbd1ace8969df83c53dac755

1 file changed, 14 insertions(+), 1 deletion(-)

changed files
M internal/storage/store.gointernal/storage/store.go
@@ -26,12 +26,20 @@ }
type Store struct { *storm.DB + new bool log *log.Logger } +const filename = "searchix.bolt" + func New(opts *Options) (*Store, error) { + exists, err := opts.Root.Exists(filename) + if err != nil { + return nil, fault.Wrap(err, fmsg.With("failed to check if file exists")) + } + //nolint:forbidigo // external package - path := opts.Root.JoinPath("searchix.bolt") + path := opts.Root.JoinPath(filename) bb, err := storm.Open(path, storm.Codec(gob.Codec), storm.BoltOptions(0o600, &bbolt.Options{
@@ -44,8 +52,13 @@ }
return &Store{ DB: bb, + new: !exists, log: opts.Logger, }, nil +} + +func (s *Store) IsNew() bool { + return s.new } func (s *Store) Close() error {