From 219ca92710ffaeefb94ebda2bc5ef13a966f4456 Mon Sep 17 00:00:00 2001 From: Rustam Gilyazov <16064414+rusq@users.noreply.github.com> Date: Sat, 21 Dec 2024 09:08:21 +1000 Subject: [PATCH] fix downloader startup --- downloader/downloader.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/downloader/downloader.go b/downloader/downloader.go index edac81e1..2ec36b39 100644 --- a/downloader/downloader.go +++ b/downloader/downloader.go @@ -144,13 +144,14 @@ type Request struct { func (c *Client) Start(ctx context.Context) { c.mu.Lock() defer c.mu.Unlock() + slog.Debug("starting downloader") - if c.started.CompareAndSwap(true, true) { - // already started + if c.started.Load() { return } c.requests = make(chan Request, c.chanBufSz) c.wg = c.startWorkers(ctx, c.requests) + c.started.Store(true) } // startWorkers starts download workers. It returns a sync.WaitGroup. If the