mirror of https://github.com/muesli/mastotool
Combine abort conditions to make the source more readable
This commit is contained in:
parent
639842eea5
commit
08bc3cd37a
17
main.go
17
main.go
|
@ -148,13 +148,7 @@ func main() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// For some reason, either because it's Pleroma or because I have too few toots,
|
abort := false
|
||||||
// `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
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, s := range statuses {
|
for _, s := range statuses {
|
||||||
err = parseToot(s, stats)
|
err = parseToot(s, stats)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -165,14 +159,15 @@ func main() {
|
||||||
pb.LazyPrint()
|
pb.LazyPrint()
|
||||||
|
|
||||||
if *maxToots > 0 && len(stats.Toots) >= *maxToots {
|
if *maxToots > 0 && len(stats.Toots) >= *maxToots {
|
||||||
|
abort = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if *maxToots > 0 && len(stats.Toots) >= *maxToots {
|
// For some reason, either because it's Pleroma or because I have too few toots,
|
||||||
break
|
// `pg.MaxID` never equals `""` and we get stuck looping forever. Add a simple
|
||||||
}
|
// break condition on "no statuses fetched" to avoid the issue.
|
||||||
if pg.MaxID == "" {
|
if abort || pg.MaxID == "" || len(statuses) == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
time.Sleep(1000 * time.Millisecond)
|
time.Sleep(1000 * time.Millisecond)
|
||||||
|
|
Loading…
Reference in New Issue