fix bug where subsequent reads of the same article come back empty
This commit is contained in:
parent
3762f7363f
commit
e91b8a4138
11
main.go
11
main.go
|
@ -122,7 +122,7 @@ func (b *backend) GetArticles(_ *nntp.Group, from, to int64) ([]nntpserver.Numbe
|
||||||
if num >= from && num <= to {
|
if num >= from && num <= to {
|
||||||
numbered = append(numbered, nntpserver.NumberedArticle{
|
numbered = append(numbered, nntpserver.NumberedArticle{
|
||||||
Num: num,
|
Num: num,
|
||||||
Article: msg,
|
Article: copyArticle(msg),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ func (b *backend) GetArticle(_ *nntp.Group, messageID string) (*nntp.Article, er
|
||||||
|
|
||||||
num, err := strconv.Atoi(messageID)
|
num, err := strconv.Atoi(messageID)
|
||||||
if err == nil && num <= len(b.messages) {
|
if err == nil && num <= len(b.messages) {
|
||||||
return b.messages[num-1], nil
|
return copyArticle(b.messages[num-1]), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nntpserver.ErrInvalidMessageID
|
return nil, nntpserver.ErrInvalidMessageID
|
||||||
|
@ -171,6 +171,13 @@ func (b backend) Post(article *nntp.Article) error {
|
||||||
return appendMessage(msg)
|
return appendMessage(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func copyArticle(article *nntp.Article) *nntp.Article {
|
||||||
|
var out nntp.Article
|
||||||
|
out = *article
|
||||||
|
out.Body = bytes.NewBuffer(article.Body.(*bytes.Buffer).Bytes())
|
||||||
|
return &out
|
||||||
|
}
|
||||||
|
|
||||||
type irisMsg struct {
|
type irisMsg struct {
|
||||||
Hash string `json:"hash"`
|
Hash string `json:"hash"`
|
||||||
EditHash *string `json:"edit_hash"`
|
EditHash *string `json:"edit_hash"`
|
||||||
|
|
Loading…
Reference in New Issue