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
|
||||
}
|
||||
|
||||
var (
|
||||
ErrQuit = errors.New("Quit")
|
||||
ErrInvalidPage = errors.New("Invalid ComicVine Page")
|
||||
)
|
||||
var ErrQuit = errors.New("Quit")
|
||||
|
||||
func (c *CVDownloader) InsertBadURL(url string) {
|
||||
c.bMut.Lock()
|
||||
@ -113,13 +110,11 @@ func (c *CVDownloader) readJson() ([]*CVResult, error) {
|
||||
}
|
||||
result, err := c.loadIssues(file_entry)
|
||||
if err != nil {
|
||||
if err == ErrInvalidPage {
|
||||
continue
|
||||
}
|
||||
return issues, err
|
||||
}
|
||||
|
||||
c.totalResults = max(result.NumberOfTotalResults, c.totalResults)
|
||||
if result.NumberOfTotalResults > c.totalResults {
|
||||
c.totalResults = result.NumberOfTotalResults
|
||||
}
|
||||
issues = append(issues, result)
|
||||
}
|
||||
return issues, nil
|
||||
@ -139,9 +134,6 @@ func (c *CVDownloader) loadIssues(file_entry fs.DirEntry) (*CVResult, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if getOffset(file_entry) != tmp.Offset {
|
||||
return nil, ErrInvalidPage
|
||||
}
|
||||
return tmp, nil
|
||||
}
|
||||
|
||||
@ -231,8 +223,6 @@ func (c *CVDownloader) updateIssues() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
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:
|
||||
}
|
||||
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)
|
||||
err = json.NewDecoder(bufio.NewReader(body)).Decode(issue)
|
||||
if err != nil || issue.Offset != offset {
|
||||
os.Remove(filepath.Join(c.JSONPath, "cv-"+strconv.Itoa(offset)+".json"))
|
||||
if err != nil {
|
||||
cancelDownloadCTX()
|
||||
if retry(URI.String(), err) {
|
||||
continue
|
||||
|
Loading…
x
Reference in New Issue
Block a user