Make DB registry persistence optional

This increases resilience when persistence is not needed.
This commit is contained in:
Daniel 2020-07-11 14:20:04 +02:00
parent fda2943c0a
commit 6fcd1d3ef7
3 changed files with 18 additions and 11 deletions

View file

@ -40,14 +40,13 @@ func Initialize(dirStructureRoot *utils.DirStructure) error {
return fmt.Errorf("could not create/open database directory (%s): %s", rootStructure.Path, err)
}
err = loadRegistry()
if err != nil {
return fmt.Errorf("could not load database registry (%s): %s", filepath.Join(rootStructure.Path, registryFileName), err)
if registryPersistence.IsSet() {
err = loadRegistry()
if err != nil {
return fmt.Errorf("could not load database registry (%s): %s", filepath.Join(rootStructure.Path, registryFileName), err)
}
}
// start registry writer
go registryWriter()
return nil
}
return errors.New("database already initialized")