From 8c67be558f697ab52740c51ab453092c0f8f7c14 Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 1 Dec 2022 17:33:00 +0100 Subject: [PATCH] fix: restore notifications table from dump when it already had the correct format --- pkg/modules/dump/restore.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/modules/dump/restore.go b/pkg/modules/dump/restore.go index 723cae2840..c5b08dee18 100644 --- a/pkg/modules/dump/restore.go +++ b/pkg/modules/dump/restore.go @@ -22,6 +22,7 @@ import ( "bytes" "encoding/base64" "encoding/json" + "errors" "fmt" "io" "os" @@ -144,11 +145,16 @@ func Restore(filename string) error { // FIXME: There has to be a general way to do this but this works for now. if table == "notifications" { for i := range content { - decoded, err := base64.StdEncoding.DecodeString(content[i]["notification"].(string)) - if err != nil { + var decoded []byte + decoded, err = base64.StdEncoding.DecodeString(content[i]["notification"].(string)) + if err != nil && !errors.Is(err, base64.CorruptInputError(0)) { return fmt.Errorf("could not decode notification %s: %w", content[i]["notification"], err) } + if err != nil && errors.Is(err, base64.CorruptInputError(0)) { + decoded = []byte(content[i]["notification"].(string)) + } + content[i]["notification"] = string(decoded) } }