Skip to content

Commit

Permalink
incr &curTry in defer on retry only
Browse files Browse the repository at this point in the history
  • Loading branch information
vbauerster committed Jul 30, 2024
1 parent 605eaf9 commit 5845617
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion part.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func (p *Part) download(

return backoff.RetryWithContext(p.ctx, exponential.New(exponential.WithBaseDelay(500*time.Millisecond)),
func(attempt uint, reset func()) (retry bool, err error) {
atomic.StoreUint32(&curTry, uint32(attempt))
ctx, cancel := context.WithCancel(p.ctx)
timer := time.AfterFunc(timeout, func() {
cancel()
Expand Down Expand Up @@ -183,6 +182,7 @@ func (p *Part) download(
p.logger.Println("Retry reason:", err.Error())
fmt.Fprintf(p.progress, "%s%s\n", p.logger.Prefix(), unwrapOrErr(err).Error())
p.logger.SetPrefix(fmt.Sprintf(prefixTemplate, attempt+1))
atomic.StoreUint32(&curTry, uint32(attempt+1))
}()

p.logger.Printf("GET(%s): %s", timeout, req.URL)
Expand Down

0 comments on commit 5845617

Please sign in to comment.