diff options
| author | nytpu <alex@nytpu.com> | 2021-03-18 13:34:02 -0600 |
|---|---|---|
| committer | nytpu <alex@nytpu.com> | 2021-03-18 13:34:02 -0600 |
| commit | 364e8fbc210ba71c2cff5bb479860ac1130e178a (patch) | |
| tree | 45047ed3061ab552ee9f06ef7f1663b0af2d829c /core | |
| parent | 6f2f4ac4b18643f2160c41db08eb8208a14bc9fc (diff) | |
fix null dereference when getting old title
Diffstat (limited to 'core')
| -rw-r--r-- | core/structs.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/structs.go b/core/structs.go index 8df60ac..693fa0b 100644 --- a/core/structs.go +++ b/core/structs.go @@ -94,6 +94,9 @@ func (d *FullData) InsertFeed(new *Feed, remote string) { oldFeed, ok := d.Feeds[remote] if !ok || !reflect.DeepEqual(new, oldFeed) { // Feeds are different, or there was never an old one + if oldFeed != nil && new.Title == "" && oldFeed.Title != "" { + new.Title = oldFeed.Title + } d.Feeds[remote] = new d.FeedsMu.Unlock() } else { @@ -104,9 +107,12 @@ func (d *FullData) InsertFeed(new *Feed, remote string) { // InsertPage will insert or update a core.Page in a core.FullData func (d *FullData) InsertPage(new *Page, remote string) { d.PagesMu.Lock() - _, ok := d.Pages[remote] + oldPage, ok := d.Pages[remote] if !ok || d.Pages[remote].Hash != new.Hash { // pages are different, or there was never an old one + if oldPage != nil && new.Title == "" && oldPage.Title != "" { + new.Title = oldPage.Title + } d.Pages[remote] = new d.PagesMu.Unlock() } else { |
