feat(download): add output path parameter to download and checkVersionInDownloaded functions
Add outputPath parameter to download and checkVersionInDownloaded functions to allow specifying the download directory. Update main function to pass the outputPath parameter to these functions.
This commit is contained in:
@ -173,7 +173,7 @@ func (wc *WriteCounter) PrintProgress() {
|
||||
fmt.Printf("\rDownloading... %.2f%% (%.2f/%.2f MB)", percentage, downloadedMB, totalMB)
|
||||
}
|
||||
|
||||
func download(host string, port int, bundleID, query, version, udid string) bool {
|
||||
func download(host string, port int, bundleID, query, version, udid, outputPath string) bool {
|
||||
linkDownload := fmt.Sprintf(
|
||||
"http://%s:%d/download?bundleID=%s", host, port, bundleID,
|
||||
)
|
||||
@ -197,7 +197,7 @@ func download(host string, port int, bundleID, query, version, udid string) bool
|
||||
return false
|
||||
}
|
||||
|
||||
fileName := filepath.Join("apps", fmt.Sprintf("%s_%s_%s.ipa", udid, query, version))
|
||||
fileName := filepath.Join(outputPath, fmt.Sprintf("%s_%s_%s.ipa", udid, query, version))
|
||||
out, err := os.Create(fileName)
|
||||
if err != nil {
|
||||
fmt.Println("error creating file:", err)
|
||||
@ -216,8 +216,8 @@ func download(host string, port int, bundleID, query, version, udid string) bool
|
||||
return true
|
||||
}
|
||||
|
||||
func checkVersionInDownloaded(udid, query, version string) bool {
|
||||
path := filepath.Join("apps", fmt.Sprintf("%s_%s_%s.ipa", udid, query, version))
|
||||
func checkVersionInDownloaded(udid, query, version, outputPath string) bool {
|
||||
path := filepath.Join(outputPath, fmt.Sprintf("%s_%s_%s.ipa", udid, query, version))
|
||||
_, err := os.Stat(path)
|
||||
return !os.IsNotExist(err)
|
||||
}
|
||||
@ -298,13 +298,13 @@ func main() {
|
||||
continue
|
||||
}
|
||||
|
||||
if checkVersionInDownloaded(*udid, *query, srFirst.Version) {
|
||||
if checkVersionInDownloaded(*udid, *query, srFirst.Version, *outputPath) {
|
||||
fmt.Println("version already downloaded, skipping...")
|
||||
time.Sleep(120 * time.Minute)
|
||||
continue
|
||||
}
|
||||
|
||||
if !download(*host, *port, srFirst.BundleID, *query, srFirst.Version, *udid) {
|
||||
if !download(*host, *port, srFirst.BundleID, *query, srFirst.Version, *udid, *outputPath) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user