mirror of
https://github.com/jeremyd/ergo.git
synced 2026-07-15 04:08:10 -07:00
implement database auto-upgrades (#243)
This commit is contained in:
+5
-7
@@ -127,7 +127,6 @@ type Server struct {
|
||||
signals chan os.Signal
|
||||
snomasks *SnoManager
|
||||
store *buntdb.DB
|
||||
storeFilename string
|
||||
stsEnabled bool
|
||||
webirc []webircConfig
|
||||
whoWas *WhoWasList
|
||||
@@ -746,7 +745,7 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
|
||||
return fmt.Errorf("Maximum line length (linelen) cannot be changed after launching the server, rehash aborted")
|
||||
} else if server.name != config.Server.Name {
|
||||
return fmt.Errorf("Server name cannot be changed after launching the server, rehash aborted")
|
||||
} else if server.storeFilename != config.Datastore.Path {
|
||||
} else if server.config.Datastore.Path != config.Datastore.Path {
|
||||
return fmt.Errorf("Datastore path cannot be changed after launching the server, rehash aborted")
|
||||
}
|
||||
}
|
||||
@@ -966,10 +965,9 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
|
||||
server.config = config
|
||||
server.configurableStateMutex.Unlock()
|
||||
|
||||
server.storeFilename = config.Datastore.Path
|
||||
server.logger.Info("rehash", "Using datastore", server.storeFilename)
|
||||
server.logger.Info("rehash", "Using datastore", config.Datastore.Path)
|
||||
if initial {
|
||||
if err := server.loadDatastore(server.storeFilename); err != nil {
|
||||
if err := server.loadDatastore(config); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -1066,11 +1064,11 @@ func (server *Server) loadMOTD(motdPath string, useFormatting bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (server *Server) loadDatastore(datastorePath string) error {
|
||||
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
|
||||
|
||||
db, err := OpenDatabase(datastorePath)
|
||||
db, err := OpenDatabase(config)
|
||||
if err == nil {
|
||||
server.store = db
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user