mirror of
https://github.com/jeremyd/ergo.git
synced 2026-07-10 02:18:11 -07:00
implement #322
Automatically create the datastore on `oragono run` if it doesn't exist. See also #302.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user