Skip to content

Commit

Permalink
fixing race condition in the downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Feb 12, 2024
1 parent 8096d26 commit 30d207d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,11 @@ func (c *Client) Stop() {
// ErrNotStarted. Will place the file to the download queue.
func (c *Client) Download(fullpath string, url string) error {
c.mu.Lock()
started := c.started
c.mu.Unlock()

if !started {
defer c.mu.Unlock()
if !c.started {
return ErrNotStarted
}

c.requests <- Request{Fullpath: fullpath, URL: url}
return nil
}
Expand Down

0 comments on commit 30d207d

Please sign in to comment.