Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
92c4f0c77a | |||
c243b76969 |
18
main.go
18
main.go
@ -188,19 +188,23 @@ func getOrDownload(results *wallhaven.SearchResults, r *rand.Rand, downloadPath
|
||||
}
|
||||
result := results.Data[r.Intn(len(results.Data))]
|
||||
fullPath := path.Join(downloadPath, path.Base(result.Path))
|
||||
if _, err := os.Stat(fullPath); err != nil {
|
||||
_, err := os.Stat(fullPath)
|
||||
if err == nil {
|
||||
return fullPath, nil
|
||||
}
|
||||
if os.IsNotExist(err) {
|
||||
err = result.Download(path.Join(downloadPath))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return fullPath, nil
|
||||
}
|
||||
return fullPath, nil
|
||||
return "", err
|
||||
}
|
||||
|
||||
func runScript(imgPath, script string) error {
|
||||
_, err := exec.Command(script, imgPath).Output()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
cmd := exec.Command(script, imgPath)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
return cmd.Run()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user