Compare commits
No commits in common. "840e97cff0e4086a2cad421ed28e94e6e07b5931" and "776ca68e3e04140045d83c363f53517151267b8f" have entirely different histories.
840e97cff0
...
776ca68e3e
25
cv/cv.go
25
cv/cv.go
@ -78,10 +78,7 @@ type CVDownloader struct {
|
|||||||
notFound chan download
|
notFound chan download
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var ErrQuit = errors.New("Quit")
|
||||||
ErrQuit = errors.New("Quit")
|
|
||||||
ErrInvalidPage = errors.New("Invalid ComicVine Page")
|
|
||||||
)
|
|
||||||
|
|
||||||
func (c *CVDownloader) InsertBadURL(url string) {
|
func (c *CVDownloader) InsertBadURL(url string) {
|
||||||
c.bMut.Lock()
|
c.bMut.Lock()
|
||||||
@ -113,13 +110,11 @@ func (c *CVDownloader) readJson() ([]*CVResult, error) {
|
|||||||
}
|
}
|
||||||
result, err := c.loadIssues(file_entry)
|
result, err := c.loadIssues(file_entry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == ErrInvalidPage {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
return issues, err
|
return issues, err
|
||||||
}
|
}
|
||||||
|
if result.NumberOfTotalResults > c.totalResults {
|
||||||
c.totalResults = max(result.NumberOfTotalResults, c.totalResults)
|
c.totalResults = result.NumberOfTotalResults
|
||||||
|
}
|
||||||
issues = append(issues, result)
|
issues = append(issues, result)
|
||||||
}
|
}
|
||||||
return issues, nil
|
return issues, nil
|
||||||
@ -139,9 +134,6 @@ func (c *CVDownloader) loadIssues(file_entry fs.DirEntry) (*CVResult, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if getOffset(file_entry) != tmp.Offset {
|
|
||||||
return nil, ErrInvalidPage
|
|
||||||
}
|
|
||||||
return tmp, nil
|
return tmp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,8 +223,6 @@ func (c *CVDownloader) updateIssues() {
|
|||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
log.Println("Failed to read page at offset ", offset, err)
|
log.Println("Failed to read page at offset ", offset, err)
|
||||||
os.Remove(filepath.Join(c.JSONPath, c.fileList[offset/100].Name()))
|
|
||||||
c.fileList = slices.Delete(c.fileList, offset/100, (offset/100)+1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Printf("Expected Offset %d got Offset %d", offset, getOffset(c.fileList[offset/100]))
|
log.Printf("Expected Offset %d got Offset %d", offset, getOffset(c.fileList[offset/100]))
|
||||||
@ -251,10 +241,6 @@ func (c *CVDownloader) updateIssues() {
|
|||||||
case c.downloadQueue <- issue:
|
case c.downloadQueue <- issue:
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
} else {
|
|
||||||
log.Println("Failed to read page at offset ", offset, err)
|
|
||||||
os.Remove(filepath.Join(c.JSONPath, c.fileList[offset/100].Name()))
|
|
||||||
c.fileList = slices.Delete(c.fileList, offset/100, (offset/100)+1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,8 +282,7 @@ func (c *CVDownloader) updateIssues() {
|
|||||||
}
|
}
|
||||||
body := io.TeeReader(resp.Body, file)
|
body := io.TeeReader(resp.Body, file)
|
||||||
err = json.NewDecoder(bufio.NewReader(body)).Decode(issue)
|
err = json.NewDecoder(bufio.NewReader(body)).Decode(issue)
|
||||||
if err != nil || issue.Offset != offset {
|
if err != nil {
|
||||||
os.Remove(filepath.Join(c.JSONPath, "cv-"+strconv.Itoa(offset)+".json"))
|
|
||||||
cancelDownloadCTX()
|
cancelDownloadCTX()
|
||||||
if retry(URI.String(), err) {
|
if retry(URI.String(), err) {
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user