fix: restore notifications table from dump when it already had the correct format
This commit is contained in:
parent
e27cd9b336
commit
8c67be558f
@ -22,6 +22,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"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.
|
// FIXME: There has to be a general way to do this but this works for now.
|
||||||
if table == "notifications" {
|
if table == "notifications" {
|
||||||
for i := range content {
|
for i := range content {
|
||||||
decoded, err := base64.StdEncoding.DecodeString(content[i]["notification"].(string))
|
var decoded []byte
|
||||||
if err != nil {
|
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)
|
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)
|
content[i]["notification"] = string(decoded)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user