From 71887d160da8d892c35c5074ca99000260848a0e Mon Sep 17 00:00:00 2001 From: beebeeoii Date: Fri, 21 Jan 2022 20:06:24 +0800 Subject: [PATCH] minor code changes for backward compat --- FyneApp.toml | 2 +- internal/app/app.go | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/FyneApp.toml b/FyneApp.toml index f18f461..85d04d5 100644 --- a/FyneApp.toml +++ b/FyneApp.toml @@ -5,4 +5,4 @@ Website = "https://github.com/beebeeoii/lominus" Name = "Lominus" ID = "com.beebeeoii.lominus" Version = "1.2.0" - Build = 116 + Build = 120 diff --git a/internal/app/app.go b/internal/app/app.go index a6d7f4c..564a4d0 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -24,11 +24,6 @@ func Init() error { os.Mkdir(baseDir, os.ModePerm) } - logInitErr := logs.Init() - if logInitErr != nil { - return logInitErr - } - preferencesPath, getPreferencesPathErr := appPref.GetPreferencesPath() if getPreferencesPathErr != nil { return getPreferencesPathErr @@ -45,6 +40,25 @@ func Init() error { if savePrefErr != nil { return savePrefErr } + } else { + preferences, getPreferencesErr := appPref.LoadPreferences(preferencesPath) + if getPreferencesErr != nil { + return getPreferencesErr + } + + if preferences.LogLevel != "info" && preferences.LogLevel != "debug" { + preferences.LogLevel = "info" + } + + savePrefErr := appPref.SavePreferences(preferencesPath, preferences) + if savePrefErr != nil { + return savePrefErr + } + } + + logInitErr := logs.Init() + if logInitErr != nil { + return logInitErr } return nil