From f1abb9d353dbd39892fc7d430edac1ae835145ac Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Wed, 6 Mar 2024 15:37:42 +0100 Subject: [PATCH] Load *ArticleList, *Taglist and *Channel correctly --- cmd/data/articles.go | 12 ++++++++++-- cmd/data/rss.go | 10 +++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cmd/data/articles.go b/cmd/data/articles.go index df28c25..32722de 100644 --- a/cmd/data/articles.go +++ b/cmd/data/articles.go @@ -140,11 +140,15 @@ func LoadArticleList(filename string) (*ArticleList, error) { return nil, fmt.Errorf("error opening key file: %v", err) } - articleList := NewArticleList() + articleList := initArticleList() if err = gob.NewDecoder(file).Decode(&articleList.articles); err != nil { return nil, fmt.Errorf("error decoding key: %v", err) } + articleList.wg.Add(1) + go articleList.start() + articleList.wg.Wait() + return articleList, nil } @@ -189,10 +193,14 @@ func LoadTagList(filename string) (*TagList, error) { } defer file.Close() - tagList := NewTagList() + tagList := initTagList() if err = gob.NewDecoder(file).Decode(&tagList.tags); err != nil { return nil, fmt.Errorf("error decoding key: %v", err) } + tagList.wg.Add(1) + go tagList.start() + tagList.wg.Wait() + return tagList, nil } diff --git a/cmd/data/rss.go b/cmd/data/rss.go index 875e267..ea8338f 100644 --- a/cmd/data/rss.go +++ b/cmd/data/rss.go @@ -70,17 +70,17 @@ func LoadChannel(filename string) (*Channel, error) { } defer file.Close() - channel := initChannel() - channel.wg.Add(1) - go channel.start() - channel.wg.Wait() - tmpChannel := new(rss.Channel) if err = gob.NewDecoder(file).Decode(tmpChannel); err != nil { return nil, fmt.Errorf("error decoding channel from file %v: %v", filename, err) } + channel := initChannel() + channel.wg.Add(1) + go channel.start() + channel.wg.Wait() channel.Set(*tmpChannel) + return channel, nil }