forked from External/ergo
implement #322
Automatically create the datastore on `oragono run` if it doesn't exist. See also #302.
This commit is contained in:
parent
847922e53d
commit
d6d3a10817
2 changed files with 27 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue