1
0
Fork 0
forked from External/ergo
Automatically create the datastore on `oragono run` if it doesn't exist.
See also #302.
This commit is contained in:
Shivaram Lingamneni 2018-12-31 01:17:44 -05:00
parent 847922e53d
commit d6d3a10817
2 changed files with 27 additions and 12 deletions

View file

@ -885,6 +885,15 @@ func (server *Server) loadDatastore(config *Config) error {
// open the datastore and load server state for which it (rather than config)
// is the source of truth
_, err := os.Stat(config.Datastore.Path)
if os.IsNotExist(err) {
server.logger.Warning("startup", "database does not exist, creating it", config.Datastore.Path)
err = initializeDB(config.Datastore.Path)
if err != nil {
return err
}
}
db, err := OpenDatabase(config)
if err == nil {
server.store = db