From 65662c57bc2aebb4a6b2cea556dcdc3359822010 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Thu, 29 Aug 2024 13:30:03 +0100 Subject: [PATCH] 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. --- api.go | 7 ++++++- css/base.css | 4 ++-- logmessages/logmessages.go | 11 ++++++----- main.go | 9 +++++---- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/api.go b/api.go index f8f339d..c09fece 100644 --- a/api.go +++ b/api.go @@ -262,7 +262,12 @@ func (app *appContext) ModifyConfig(gc *gin.Context) { newSection := ns.(map[string]any) iniSection, err := tempConfig.GetSection(section.Section) 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 { newValue, ok := newSection[setting.Setting] diff --git a/css/base.css b/css/base.css index 7c1bf35..d9b53e6 100644 --- a/css/base.css +++ b/css/base.css @@ -465,8 +465,8 @@ section.section:not(.\~neutral) { } @layer components { - .switch input { - @apply mr-1; + .switch { + @apply flex flex-row gap-1 items-center; } } diff --git a/logmessages/logmessages.go b/logmessages/logmessages.go index 6dae416..4727250 100644 --- a/logmessages/logmessages.go +++ b/logmessages/logmessages.go @@ -28,11 +28,12 @@ const ( FailedStat = "Failed to stat \"%s\": %v" PathNotFound = "Path \"%s\" not found" - CopyConfig = "Copied default configuration to \"%s\"" - FailedCopyConfig = "Failed to copy default configuration to \"%s\": %v" - LoadConfig = "Loaded config file \"%s\"" - FailedLoadConfig = "Failed to load config file \"%s\": %v" - ModifyConfig = "Config saved to \"%s\"" + CopyConfig = "Copied default configuration to \"%s\"" + FailedCopyConfig = "Failed to copy default configuration to \"%s\": %v" + LoadConfig = "Loaded config file \"%s\"" + FailedLoadConfig = "Failed to load config file \"%s\": %v" + ModifyConfig = "Config saved to \"%s\"" + FailedModifyConfig = "Failed to modify config file \"%s\": %v" SocketPath = "Socket Path: \"%s\"" FailedSocketConnect = "Couldn't establish socket connection at \"%s\": %v" diff --git a/main.go b/main.go index 3b98c8c..e226dc7 100644 --- a/main.go +++ b/main.go @@ -327,6 +327,11 @@ func start(asDaemon, firstCall bool) { 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 { app.host = app.config.Section("ui").Key("host").String() if app.config.Section("advanced").Key("tls").MustBool(false) { @@ -389,10 +394,6 @@ func start(asDaemon, firstCall bool) { app.ConnectDB() 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. app.PatchConfigBase()