mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 09:00:10 +00:00
print error and include in txt log on crash; fix email migration
This commit is contained in:
parent
5b319d6612
commit
1bfec54c93
4
exit.go
4
exit.go
@ -50,6 +50,10 @@ func Exit(err interface{}) {
|
|||||||
log.Fatalf("Failed to load template: %v", err)
|
log.Fatalf("Failed to load template: %v", err)
|
||||||
}
|
}
|
||||||
logCache := lineCache.String()
|
logCache := lineCache.String()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
logCache += "\n" + fmt.Sprint(err)
|
||||||
|
}
|
||||||
logCache += "\n" + string(debug.Stack())
|
logCache += "\n" + string(debug.Stack())
|
||||||
sanitized := sanitizeLog(logCache)
|
sanitized := sanitizeLog(logCache)
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
|
@ -90,11 +90,27 @@ func migrateEmailStorage(app *appContext) error {
|
|||||||
}
|
}
|
||||||
newEmails := map[string]EmailAddress{}
|
newEmails := map[string]EmailAddress{}
|
||||||
for jfID, addr := range emails {
|
for jfID, addr := range emails {
|
||||||
newEmails[jfID] = EmailAddress{
|
switch addr.(type) {
|
||||||
Addr: addr.(string),
|
case string:
|
||||||
Contact: true,
|
newEmails[jfID] = EmailAddress{
|
||||||
|
Addr: addr.(string),
|
||||||
|
Contact: true,
|
||||||
|
}
|
||||||
|
// In case email settings still persist after migration has already happened
|
||||||
|
case map[string]interface{}:
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("Email address was type %T, not string: \"%+v\"\n", addr, addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
config, err := ini.Load(app.configPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
config.Section("email").Key("use_24h").SetValue("")
|
||||||
|
if err := config.SaveTo(app.configPath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
err = storeJSON(app.storage.emails_path+".bak", emails)
|
err = storeJSON(app.storage.emails_path+".bak", emails)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user