fix file exists check
This commit is contained in:
parent
c243b76969
commit
92c4f0c77a
9
main.go
9
main.go
@ -188,14 +188,19 @@ 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 "", err
|
||||
}
|
||||
|
||||
func runScript(imgPath, script string) error {
|
||||
cmd := exec.Command(script, imgPath)
|
||||
|
Loading…
Reference in New Issue
Block a user