From 95fa44fb97b08f40a5e39031dbd387bc5cd03502 Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Fri, 18 Oct 2024 14:35:29 -0700 Subject: [PATCH] Fix mutex on badURLs --- cv/cv.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cv/cv.go b/cv/cv.go index 2f0b804..b7b4dd3 100644 --- a/cv/cv.go +++ b/cv/cv.go @@ -97,6 +97,8 @@ func (c *CVDownloader) InsertBadURLs(url ...string) { slices.Sort(c.badURLs) } func (c *CVDownloader) IsBadURL(url string) bool { + c.bMut.Lock() + defer c.bMut.Unlock() _, itemFound := slices.BinarySearch(c.badURLs, url) return itemFound } @@ -400,9 +402,9 @@ func (c *CVDownloader) handleNotFound() { if err != nil { panic(err) } + defer file.Close() _, err = file.Seek(0, io.SeekEnd) if err != nil { - file.Close() panic(err) } for failedDownload := range c.notFound { @@ -412,7 +414,6 @@ func (c *CVDownloader) handleNotFound() { file.Write([]byte("\n")) file.Sync() } - file.Close() } func (c *CVDownloader) downloadImages() {