diff --git a/internal/pcscommand/download.go b/internal/pcscommand/download.go index 618ba964..f389222b 100644 --- a/internal/pcscommand/download.go +++ b/internal/pcscommand/download.go @@ -62,14 +62,15 @@ func downloadPrintFormat(load int) string { func download(id int, downloadURL, savePath string, loadBalansers []string, client *requester.HTTPClient, cfg *downloader.Config, downloadOptions *DownloadOptions) error { var ( + newCfg = cfg.Copy() file *os.File writerAt io.WriterAt err error exitChan chan struct{} ) - if !cfg.IsTest { - cfg.InstanceStatePath = savePath + DownloadSuffix + if !newCfg.IsTest { + newCfg.InstanceStatePath = savePath + DownloadSuffix // 创建下载的目录 dir := filepath.Dir(savePath) @@ -119,7 +120,7 @@ func download(id int, downloadURL, savePath string, loadBalansers []string, clie }() } - if cfg.IsTest { + if newCfg.IsTest { fmt.Fprintf(downloadOptions.Out, "[%d] 测试下载开始\n\n", id) } @@ -176,7 +177,7 @@ func download(id int, downloadURL, savePath string, loadBalansers []string, clie } } - if !cfg.IsTest { + if !newCfg.IsTest { fmt.Fprintf(downloadOptions.Out, "[%d] 下载完成, 保存位置: %s\n", id, savePath) } else { fmt.Fprintf(downloadOptions.Out, "[%d] 测试下载结束\n", id) diff --git a/requester/downloader/config.go b/requester/downloader/config.go index b958bc43..3e82554e 100644 --- a/requester/downloader/config.go +++ b/requester/downloader/config.go @@ -36,3 +36,9 @@ func (cfg *Config) Fix() { cfg.MaxParallel = 1 } } + +//Copy 拷贝新的配置 +func (cfg *Config) Copy() *Config { + newCfg := *cfg + return &newCfg +}