优化
This commit is contained in:
@@ -172,11 +172,12 @@ func (d *Data) persistConfigValuesLocked(dataConfig *conf.Data, adminConfig *con
|
||||
return writeConfigDocument(configPath, &document)
|
||||
}
|
||||
|
||||
// persistDatabaseConfig writes only the database selected on the init page.
|
||||
// Initialization must not serialize the partially populated runtime config
|
||||
// back over the template: doing so removes all omitted/default settings from
|
||||
// data and admin and leaves the next startup with no visible configuration.
|
||||
func (d *Data) persistDatabaseConfig(database *conf.Data_Database) error {
|
||||
// persistDatabaseConfig writes only the database selected on the init page and
|
||||
// the freshly generated JWT signing key. Initialization must not serialize the
|
||||
// partially populated runtime config back over the template: doing so removes
|
||||
// all omitted/default settings from data and admin and leaves the next startup
|
||||
// with no visible configuration.
|
||||
func (d *Data) persistDatabaseConfig(database *conf.Data_Database, signingKey string) error {
|
||||
d.configMu.Lock()
|
||||
defer d.configMu.Unlock()
|
||||
|
||||
@@ -215,6 +216,11 @@ func (d *Data) persistDatabaseConfig(database *conf.Data_Database) error {
|
||||
if err = setYAMLMapping(&document, "data", map[string]any{"database": databaseValue}); err != nil {
|
||||
return err
|
||||
}
|
||||
if signingKey != "" {
|
||||
if err = setYAMLMapping(&document, "admin", map[string]any{"jwt": map[string]any{"signing_key": signingKey}}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return writeConfigDocument(configPath, &document)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user