Fix mutex on badURLs

This commit is contained in:
Timmy Welch 2024-10-18 14:35:29 -07:00
parent d0c7ed792a
commit 95fa44fb97

View File

@ -97,6 +97,8 @@ func (c *CVDownloader) InsertBadURLs(url ...string) {
slices.Sort(c.badURLs) slices.Sort(c.badURLs)
} }
func (c *CVDownloader) IsBadURL(url string) bool { func (c *CVDownloader) IsBadURL(url string) bool {
c.bMut.Lock()
defer c.bMut.Unlock()
_, itemFound := slices.BinarySearch(c.badURLs, url) _, itemFound := slices.BinarySearch(c.badURLs, url)
return itemFound return itemFound
} }
@ -400,9 +402,9 @@ func (c *CVDownloader) handleNotFound() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
defer file.Close()
_, err = file.Seek(0, io.SeekEnd) _, err = file.Seek(0, io.SeekEnd)
if err != nil { if err != nil {
file.Close()
panic(err) panic(err)
} }
for failedDownload := range c.notFound { for failedDownload := range c.notFound {
@ -412,7 +414,6 @@ func (c *CVDownloader) handleNotFound() {
file.Write([]byte("\n")) file.Write([]byte("\n"))
file.Sync() file.Sync()
} }
file.Close()
} }
func (c *CVDownloader) downloadImages() { func (c *CVDownloader) downloadImages() {