Load *ArticleList, *Taglist and *Channel correctly
This commit is contained in:
parent
6baaec5b33
commit
f1abb9d353
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user