Archived
1
0

Merge pull request #151 from cathugger/master

some fixes
This commit is contained in:
Jeff 2018-01-22 12:35:32 -05:00 committed by GitHub
commit 685153f94e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1328,6 +1328,9 @@ func (self *nntpConnection) scrapeGroup(daemon *NNTPDaemon, conn *textproto.Conn
// something bad went down when reading multiline // something bad went down when reading multiline
log.Println(self.name, "failed to read multiline for", group, "XOVER command") log.Println(self.name, "failed to read multiline for", group, "XOVER command")
} }
} else if code >= 420 || code <= 429 {
// group doesn't have articles in one way or another. not really error
err = nil
} }
} }
} else if err == nil { } else if err == nil {
@ -1379,12 +1382,16 @@ func (self *nntpConnection) scrapeServer(daemon *NNTPDaemon, conn *textproto.Con
sc := bufio.NewScanner(dr) sc := bufio.NewScanner(dr)
for sc.Scan() { for sc.Scan() {
line := sc.Text() line := sc.Text()
idx := strings.Index(line, " ") idx := strings.IndexAny(line, " \t")
if idx > 0 { if idx > 0 {
//log.Println(self.name, "got newsgroup", line[:idx])
groups = append(groups, line[:idx]) groups = append(groups, line[:idx])
} else if idx < 0 {
//log.Println(self.name, "got newsgroup", line)
groups = append(groups, line)
} else { } else {
// invalid line? wtf. // can't have it starting with WS
log.Println(self.name, "invalid line in newsgroups multiline response:", line) log.Printf("%s invalid line in newsgroups multiline response [%s]\n", self.name, line)
} }
} }
err = sc.Err() err = sc.Err()
@ -1402,8 +1409,8 @@ func (self *nntpConnection) scrapeServer(daemon *NNTPDaemon, conn *textproto.Con
// scrape the group // scrape the group
err = self.scrapeGroup(daemon, conn, group) err = self.scrapeGroup(daemon, conn, group)
if err != nil { if err != nil {
log.Println(self.name, "did not scrape", group, err) log.Println(self.name, "failure scraping group", group, "error:", err)
break // do not break here, continue with other groups
} }
} }
} else { } else {