Compare commits

..

No commits in common. "master" and "v0.0.1" have entirely different histories.

2 changed files with 11 additions and 13 deletions

View File

@ -8,7 +8,9 @@ before:
- go mod tidy - go mod tidy
builds: builds:
- goos: - env:
- CGO_ENABLED=0
goos:
- linux - linux
- windows - windows
- darwin - darwin
@ -16,7 +18,7 @@ builds:
- goos: windows - goos: windows
goarch: "386" goarch: "386"
ldflags: ldflags:
- -s -w -X main.Version={{.Version}} - -s -w -X git.asdf.cafe/abs3nt/wallhaven_dl/main.Version={{.Version}}
archives: archives:
- format: tar.gz - format: tar.gz

18
main.go
View File

@ -188,23 +188,19 @@ 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))
_, err := os.Stat(fullPath) if _, err := os.Stat(fullPath); err != nil {
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 "", err return fullPath, nil
} }
func runScript(imgPath, script string) error { func runScript(imgPath, script string) error {
cmd := exec.Command(script, imgPath) _, err := exec.Command(script, imgPath).Output()
cmd.Stdout = os.Stdout if err != nil {
cmd.Stderr = os.Stderr return err
return cmd.Run() }
return nil
} }