Skip to content

Commit

Permalink
Rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpl0itU committed Aug 29, 2023
1 parent c888aa7 commit c906b6a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type ProgressReporter interface {
Cancelled() bool
}

func downloadFile(progressWindow ProgressReporter, client *grab.Client, downloadURL string, dstPath string, doRetries bool) error {
func downloadFile(progressReporter ProgressReporter, client *grab.Client, downloadURL string, dstPath string, doRetries bool) error {
filePath := filepath.Base(dstPath)

for attempt := 1; attempt <= maxRetries; attempt++ {
Expand All @@ -39,7 +39,7 @@ func downloadFile(progressWindow ProgressReporter, client *grab.Client, download
req.BufferSize = bufferSize

resp := client.Do(req)
progressWindow.UpdateDownloadProgress(resp, filePath)
progressReporter.UpdateDownloadProgress(resp, filePath)

t := time.NewTicker(500 * time.Millisecond)
defer t.Stop()
Expand All @@ -48,8 +48,8 @@ func downloadFile(progressWindow ProgressReporter, client *grab.Client, download
for {
select {
case <-t.C:
progressWindow.UpdateDownloadProgress(resp, filePath)
if progressWindow.Cancelled() {
progressReporter.UpdateDownloadProgress(resp, filePath)
if progressReporter.Cancelled() {
resp.Cancel()
break Loop
}
Expand Down

0 comments on commit c906b6a

Please sign in to comment.