fix file exists check
All checks were successful
builder / build (push) Successful in 19s
deployer / go-releaser (push) Successful in 29s

This commit is contained in:
abs3nt 2024-07-20 19:26:22 -07:00
parent c243b76969
commit 92c4f0c77a
Signed by: abs3nt
GPG Key ID: A7BD96A8BAB04C09

View File

@ -188,13 +188,18 @@ func getOrDownload(results *wallhaven.SearchResults, r *rand.Rand, downloadPath
} }
result := results.Data[r.Intn(len(results.Data))] result := results.Data[r.Intn(len(results.Data))]
fullPath := path.Join(downloadPath, path.Base(result.Path)) 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)) err = result.Download(path.Join(downloadPath))
if err != nil { if err != nil {
return "", err return "", err
} }
return fullPath, nil
} }
return fullPath, nil return "", err
} }
func runScript(imgPath, script string) error { func runScript(imgPath, script string) error {