From d64f6c3d8f33d71077b756323451575cc0f9fc10 Mon Sep 17 00:00:00 2001 From: trojvn Date: Wed, 11 Mar 2026 20:06:33 +0300 Subject: [PATCH] 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. --- client/main.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/main.go b/client/main.go index 00b701a..24731fc 100644 --- a/client/main.go +++ b/client/main.go @@ -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 }