Skip to content

Commit

Permalink
Fix panic when RequestJobLimit is not set
Browse files Browse the repository at this point in the history
If the RequestJobLimit is not set, it resulted in a panic. This commit
fixes it by setting the limit to the job number in such cases.
  • Loading branch information
grisu48 committed Jan 15, 2025
1 parent 8807bb9 commit a927c92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/openqa-revtui/openqa-revtui.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func parseProgramArgs(cf *Config) ([]Config, error) {
}
filename := os.Args[i]
var cf Config
cf.RequestJobLimit = 100 // Set default limit
if err := cf.LoadToml(filename); err != nil {
return cfs, fmt.Errorf("in %s: %s", filename, err)
}
Expand Down
8 changes: 6 additions & 2 deletions cmd/openqa-revtui/openqa.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@ func fetchJobsFollow(ids []int64, model *TUIModel, progress func(i, n int)) ([]g
// We split the job ids into multiple requests if necessary
jobs := make([]gopenqa.Job, 0)
// Progress variables
chunks := len(ids) / model.Config.RequestJobLimit
limit := model.Config.RequestJobLimit
if limit <= 0 {
limit = len(ids)
}
chunks := len(ids) / limit
for i := 0; len(ids) > 0; i++ { // Repeat until no more ids are available.
n := min(model.Config.RequestJobLimit, len(ids))
n := min(limit, len(ids))
chunk, err := model.Instance.GetJobsFollow(ids[:n])
if progress != nil {
progress(i, chunks)
Expand Down

0 comments on commit a927c92

Please sign in to comment.