Combine abort conditions to make the source more readable

This commit is contained in:
Christian Muehlhaeuser 2018-11-23 03:56:07 +01:00
parent 639842eea5
commit 08bc3cd37a
No known key found for this signature in database
GPG Key ID: 3CF9FA45CA1EBB7E
1 changed files with 6 additions and 11 deletions

17
main.go
View File

@ -148,13 +148,7 @@ func main() {
panic(err)
}
// For some reason, either because it's Pleroma or because I have too few toots,
// `pg.MaxID` never equals `""` and we get stuck looping forever. Add a simple
// break condition on "no statuses fetched" to avoid the issue.
if len(statuses) == 0 {
break
}
abort := false
for _, s := range statuses {
err = parseToot(s, stats)
if err != nil {
@ -165,14 +159,15 @@ func main() {
pb.LazyPrint()
if *maxToots > 0 && len(stats.Toots) >= *maxToots {
abort = true
break
}
}
if *maxToots > 0 && len(stats.Toots) >= *maxToots {
break
}
if pg.MaxID == "" {
// For some reason, either because it's Pleroma or because I have too few toots,
// `pg.MaxID` never equals `""` and we get stuck looping forever. Add a simple
// break condition on "no statuses fetched" to avoid the issue.
if abort || pg.MaxID == "" || len(statuses) == 0 {
break
}
time.Sleep(1000 * time.Millisecond)