🐛 Reset recent-doc.json on unmarshal failure (#16251)

This commit is contained in:
Jeffrey Chen 2025-10-31 10:12:56 +08:00 committed by GitHub
parent ff0bcce914
commit d76c63a456
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -232,6 +232,10 @@ func getRecentDocs(sortBy string) (ret []*RecentDoc, err error) {
if err = gulu.JSON.UnmarshalJSON(data, &tmp); err != nil {
logging.LogErrorf("unmarshal storage [recent-doc] failed: %s", err)
if err = setRecentDocs([]*RecentDoc{}); err != nil {
logging.LogErrorf("reset storage [recent-doc] failed: %s", err)
}
ret = []*RecentDoc{}
return
}