Add check exist files
This commit is contained in:
parent
b008b67bcb
commit
4cc6c079b3
6
main.go
6
main.go
|
@ -229,6 +229,9 @@ func getSavePath(post *Post, directory *string) string {
|
||||||
func downloadPost(post *Post, directory string, transport http.Transport) error {
|
func downloadPost(post *Post, directory string, transport http.Transport) error {
|
||||||
savePath := getSavePath(post, &directory)
|
savePath := getSavePath(post, &directory)
|
||||||
|
|
||||||
|
if _, err := os.Stat(savePath); err == nil {
|
||||||
|
fmt.Print("File exists, skip...\n")
|
||||||
|
} else {
|
||||||
resp, err := HTTPGet(post.FileURL, transport)
|
resp, err := HTTPGet(post.FileURL, transport)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -245,6 +248,7 @@ func downloadPost(post *Post, directory string, transport http.Transport) error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -264,7 +268,7 @@ func main() {
|
||||||
tags := flag.String("tags", "", "Tags to search for")
|
tags := flag.String("tags", "", "Tags to search for")
|
||||||
maxConcurrents := flag.Int("concurrents", 30, "Maximum amount of concurrent downloads")
|
maxConcurrents := flag.Int("concurrents", 30, "Maximum amount of concurrent downloads")
|
||||||
saveDirectory := flag.String("out", "dl", "The directory to write the downloaded posts to")
|
saveDirectory := flag.String("out", "dl", "The directory to write the downloaded posts to")
|
||||||
postLimit := flag.Int("limit", 1000, "Maximum amount of posts to grab from e621")
|
postLimit := flag.Int("limit", 9999999999, "Maximum amount of posts to grab from e621")
|
||||||
proxyAddr := flag.String("proxy", "", "Proxy address to parsing")
|
proxyAddr := flag.String("proxy", "", "Proxy address to parsing")
|
||||||
timeout := flag.Int("timeout", 10, "Timeout proxy to parsing")
|
timeout := flag.Int("timeout", 10, "Timeout proxy to parsing")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue