1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-11-09 20:00:12 +00:00

setup: fix config application

recent change means app.ModifyConfig requires app.confiBase, which was
not read in from the YAML file in setup. It is now loaded before the "if
!firstRun" branch.
This commit is contained in:
Harvey Tindall 2024-08-29 13:30:03 +01:00
parent 3559e32c2f
commit 65662c57bc
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2
4 changed files with 19 additions and 12 deletions

7
api.go
View File

@ -262,7 +262,12 @@ func (app *appContext) ModifyConfig(gc *gin.Context) {
newSection := ns.(map[string]any) newSection := ns.(map[string]any)
iniSection, err := tempConfig.GetSection(section.Section) iniSection, err := tempConfig.GetSection(section.Section)
if err != nil { if err != nil {
iniSection, _ = tempConfig.NewSection(section.Section) iniSection, err = tempConfig.NewSection(section.Section)
if err != nil {
app.err.Printf(lm.FailedModifyConfig, app.configPath, err)
respond(500, err.Error(), gc)
return
}
} }
for _, setting := range section.Settings { for _, setting := range section.Settings {
newValue, ok := newSection[setting.Setting] newValue, ok := newSection[setting.Setting]

View File

@ -465,8 +465,8 @@ section.section:not(.\~neutral) {
} }
@layer components { @layer components {
.switch input { .switch {
@apply mr-1; @apply flex flex-row gap-1 items-center;
} }
} }

View File

@ -33,6 +33,7 @@ const (
LoadConfig = "Loaded config file \"%s\"" LoadConfig = "Loaded config file \"%s\""
FailedLoadConfig = "Failed to load config file \"%s\": %v" FailedLoadConfig = "Failed to load config file \"%s\": %v"
ModifyConfig = "Config saved to \"%s\"" ModifyConfig = "Config saved to \"%s\""
FailedModifyConfig = "Failed to modify config file \"%s\": %v"
SocketPath = "Socket Path: \"%s\"" SocketPath = "Socket Path: \"%s\""
FailedSocketConnect = "Couldn't establish socket connection at \"%s\": %v" FailedSocketConnect = "Couldn't establish socket connection at \"%s\": %v"

View File

@ -327,6 +327,11 @@ func start(asDaemon, firstCall bool) {
app.info.Fatalf(lm.FailedLangLoad, err) app.info.Fatalf(lm.FailedLangLoad, err)
} }
// Read config-base for settings on web.
app.configBasePath = "config-base.yaml"
configBase, _ := fs.ReadFile(localFS, app.configBasePath)
yaml.Unmarshal(configBase, &app.configBase)
if !firstRun { if !firstRun {
app.host = app.config.Section("ui").Key("host").String() app.host = app.config.Section("ui").Key("host").String()
if app.config.Section("advanced").Key("tls").MustBool(false) { if app.config.Section("advanced").Key("tls").MustBool(false) {
@ -389,10 +394,6 @@ func start(asDaemon, firstCall bool) {
app.ConnectDB() app.ConnectDB()
defer app.storage.db.Close() defer app.storage.db.Close()
// Read config-base for settings on web.
app.configBasePath = "config-base.yaml"
configBase, _ := fs.ReadFile(localFS, app.configBasePath)
yaml.Unmarshal(configBase, &app.configBase)
// copy it to app.patchedConfig, and patch in settings from app.config, and language stuff. // copy it to app.patchedConfig, and patch in settings from app.config, and language stuff.
app.PatchConfigBase() app.PatchConfigBase()