From 0e58e069cbf0abd362ac5d2631ff520a1e64901e Mon Sep 17 00:00:00 2001 From: Xpl0itU <24777100+Xpl0itU@users.noreply.github.com> Date: Sun, 14 Apr 2024 00:08:33 +0200 Subject: [PATCH] Close ticker --- downloader.go | 2 ++ writerProgress.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/downloader.go b/downloader.go index 9e1f653..a53ecbf 100644 --- a/downloader.go +++ b/downloader.go @@ -82,6 +82,7 @@ func downloadFileWithSemaphore(ctx context.Context, progressReporter ProgressRep if err != nil { file.Close() resp.Body.Close() + writerProgress.Close() if doRetries && attempt < maxRetries && !progressReporter.Cancelled() { time.Sleep(retryDelay) continue @@ -90,6 +91,7 @@ func downloadFileWithSemaphore(ctx context.Context, progressReporter ProgressRep } file.Close() resp.Body.Close() + writerProgress.Close() break } diff --git a/writerProgress.go b/writerProgress.go index 051d4dd..a5df0e9 100644 --- a/writerProgress.go +++ b/writerProgress.go @@ -33,3 +33,8 @@ func (r *WriterProgress) Write(p []byte) (n int, err error) { r.downloadToReport += int64(n) return n, err } + +func (r *WriterProgress) Close() error { + r.updateProgressTicker.Stop() + return nil +}