restrict the upload/download parallel number to fix issue #67

This commit is contained in:
xiaoyaofenfen 2022-03-21 19:51:11 +08:00
parent 85eb4ce2c4
commit e2fd95c557
3 changed files with 15 additions and 2 deletions

View File

@ -149,7 +149,7 @@ func CmdDownload() cli.Command {
},
cli.IntFlag{
Name: "p",
Usage: "指定同时进行下载文件的数量",
Usage: "指定同时进行下载文件的数量(取值范围:1 ~ 20",
},
cli.IntFlag{
Name: "retry",
@ -227,6 +227,9 @@ func RunDownload(paths []string, options *DownloadOptions) {
options.Parallel = config.DefaultFileDownloadParallelNum
}
}
if options.Parallel > config.MaxFileDownloadParallelNum {
options.Parallel = config.MaxFileDownloadParallelNum
}
paths, err := matchPathByShellPattern(options.DriveId, paths...)
if err != nil {

View File

@ -70,7 +70,7 @@ type (
var UploadFlags = []cli.Flag{
cli.IntFlag{
Name: "p",
Usage: "本次操作文件上传并发数量即可以同时并发上传多少个文件。0代表跟从配置文件设置",
Usage: "本次操作文件上传并发数量即可以同时并发上传多少个文件。0代表跟从配置文件设置(取值范围:1 ~ 20",
Value: 0,
},
cli.IntFlag{
@ -253,6 +253,10 @@ func RunUpload(localPaths []string, savePath string, opt *UploadOptions) {
opt.AllParallel = config.DefaultFileUploadParallelNum
}
}
if opt.AllParallel > config.MaxFileUploadParallelNum {
opt.AllParallel = config.MaxFileUploadParallelNum
}
if opt.Parallel <= 0 {
opt.Parallel = 1
}

View File

@ -42,9 +42,15 @@ const (
// DefaultFileUploadParallelNum 默认的文件上传并发数量
DefaultFileUploadParallelNum = 10
// MaxFileUploadParallelNum 最大文件上传并发数量。过大会被阿里云盘风控,导致无法上传
MaxFileUploadParallelNum = 20
// DefaultFileDownloadParallelNum 默认的文件下载并发数量
DefaultFileDownloadParallelNum = 5
// MaxFileDownloadParallelNum 最大文件下载并发数量。过大会被阿里云盘风控,导致无法下载
MaxFileDownloadParallelNum = 20
// DefaultTokenServiceWebHost 默认的token服务
DefaultTokenServiceWebHost = "https://api.tickstep.com"
//DefaultTokenServiceWebHost = "http://localhost:8977"