Skip to content

Commit

Permalink
refactor: cleanup action code
Browse files Browse the repository at this point in the history
  • Loading branch information
apricote committed Aug 21, 2023
1 parent d989482 commit ba2b4f8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hcloud/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ func (c *ActionClient) WatchOverallProgress(ctx context.Context, actions []*Acti
}
}

progress += (len(completedIDs) * 100)
progress += len(completedIDs) * 100
if progress != 0 && progress != previousProgress {
sendProgress(progressCh, int(progress/len(actions)))
sendProgress(progressCh, progress/len(actions))
previousProgress = progress
}

Expand Down Expand Up @@ -276,6 +276,7 @@ func (c *ActionClient) WatchProgress(ctx context.Context, action *Action) (<-cha
return progressCh, errCh
}

// sendProgress allows the user to only read from the error channel and ignore any progress updates.
func sendProgress(progressCh chan int, p int) {
select {
case progressCh <- p:
Expand Down

0 comments on commit ba2b4f8

Please sign in to comment.