Fixed errcheck linter complaints

This commit is contained in:
2019-06-05 15:45:54 +09:00
parent 190a85fe08
commit 940e949a30
15 changed files with 112 additions and 33 deletions

View File

@ -41,7 +41,11 @@ func startJobs() {
// Log paths
logsPath := path.Join(arn.Root, "logs")
jobLogsPath := path.Join(arn.Root, "logs", "jobs")
os.Mkdir(jobLogsPath, 0777)
err := os.Mkdir(jobLogsPath, 0777)
if err != nil {
panic(err)
}
// Scheduler log
mainLog := log.New()

View File

@ -31,8 +31,17 @@ func main() {
defer color.Green("Finished.")
// Create directories in case they're missing
os.Mkdir(animeDirectory, 0777)
os.Mkdir(characterDirectory, 0777)
err := os.Mkdir(animeDirectory, 0777)
if err != nil {
panic(err)
}
err = os.Mkdir(characterDirectory, 0777)
if err != nil {
panic(err)
}
// Called with arguments?
if InvokeShellArgs() {
@ -128,11 +137,15 @@ func queueAnime(anime *arn.Anime, malCrawler *crawler.Crawler) {
return
}
malCrawler.Queue(&crawler.Task{
err = malCrawler.Queue(&crawler.Task{
URL: url,
Destination: filePath,
Raw: true,
})
if err != nil {
panic(err)
}
}
func queueCharacter(character *arn.Character, malCrawler *crawler.Crawler) {
@ -146,9 +159,13 @@ func queueCharacter(character *arn.Character, malCrawler *crawler.Crawler) {
return
}
malCrawler.Queue(&crawler.Task{
err = malCrawler.Queue(&crawler.Task{
URL: url,
Destination: filePath,
Raw: true,
})
if err != nil {
panic(err)
}
}

View File

@ -35,7 +35,7 @@ func main() {
func readFiles(root string, onFile func(string) error) {
count := 0
filepath.Walk(root, func(name string, info os.FileInfo, err error) error {
err := filepath.Walk(root, func(name string, info os.FileInfo, err error) error {
if err != nil {
color.Red(err.Error())
return err
@ -61,6 +61,10 @@ func readFiles(root string, onFile func(string) error) {
return nil
})
if err != nil {
panic(err)
}
// Erase line
print("\r\033[2K")

View File

@ -30,7 +30,11 @@ func InvokeShellArgs() bool {
panic("No MAL ID")
}
readAnimeFile(path.Join(arn.Root, "jobs", "mal-download", "anime", anime.GetMapping("myanimelist/anime")+".html.gz"))
err = readAnimeFile(path.Join(arn.Root, "jobs", "mal-download", "anime", anime.GetMapping("myanimelist/anime")+".html.gz"))
if err != nil {
panic(err)
}
case "character":
character, err := arn.GetCharacter(objectID)
@ -40,7 +44,11 @@ func InvokeShellArgs() bool {
panic("No MAL ID")
}
readCharacterFile(path.Join(arn.Root, "jobs", "mal-download", "character", character.GetMapping("myanimelist/character")+".html.gz"))
err = readCharacterFile(path.Join(arn.Root, "jobs", "mal-download", "character", character.GetMapping("myanimelist/character")+".html.gz"))
if err != nil {
panic(err)
}
}
return true

View File

@ -46,7 +46,12 @@ func main() {
}
// Refresh
anime.RefreshEpisodes()
err := anime.RefreshEpisodes()
if err != nil {
color.Red(err.Error())
continue
}
// Ok
color.Green("Found %d episodes for anime %s (Kitsu: %s)", len(anime.Episodes().Items), anime.ID, kitsuID)