File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -58,8 +58,13 @@ func (d *BaiduNetdisk) GetAddition() driver.Additional {
5858}
5959
6060func (d * BaiduNetdisk ) Init (ctx context.Context ) error {
61+ timeout := DEFAULT_UPLOAD_SLICE_TIMEOUT
62+ if d .UploadSliceTimeout > 0 {
63+ timeout = time .Second * time .Duration (d .UploadSliceTimeout )
64+ }
65+
6166 d .upClient = base .NewRestyClient ().
62- SetTimeout (UPLOAD_TIMEOUT ).
67+ SetTimeout (timeout ).
6368 SetRetryCount (UPLOAD_RETRY_COUNT ).
6469 SetRetryWaitTime (UPLOAD_RETRY_WAIT_TIME ).
6570 SetRetryMaxWaitTime (UPLOAD_RETRY_MAX_WAIT_TIME )
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ type Addition struct {
1919 AccessToken string
2020 RefreshToken string `json:"refresh_token" required:"true"`
2121 UploadThread string `json:"upload_thread" default:"3" help:"1<=thread<=32"`
22+ UploadSliceTimeout int `json:"upload_timeout" type:"number" default:"60" help:"per-slice upload timeout in seconds"`
2223 UploadAPI string `json:"upload_api" default:"https://d.pcs.baidu.com"`
2324 UseDynamicUploadAPI bool `json:"use_dynamic_upload_api" default:"true" help:"dynamically get upload api domain, when enabled, the 'Upload API' setting will be used as a fallback if failed to get"`
2425 CustomUploadPartSize int64 `json:"custom_upload_part_size" type:"number" default:"0" help:"0 for auto"`
@@ -27,12 +28,12 @@ type Addition struct {
2728}
2829
2930const (
30- UPLOAD_FALLBACK_API = "https://d.pcs.baidu.com" // 备用上传地址
31- UPLOAD_URL_EXPIRE_TIME = time .Minute * 60 // 上传地址有效期(分钟)
32- UPLOAD_TIMEOUT = time .Minute * 30 // 上传请求超时时间
33- UPLOAD_RETRY_COUNT = 3
34- UPLOAD_RETRY_WAIT_TIME = time .Second * 1
35- UPLOAD_RETRY_MAX_WAIT_TIME = time .Second * 5
31+ UPLOAD_FALLBACK_API = "https://d.pcs.baidu.com" // 备用上传地址
32+ UPLOAD_URL_EXPIRE_TIME = time .Minute * 60 // 上传地址有效期(分钟)
33+ DEFAULT_UPLOAD_SLICE_TIMEOUT = time .Second * 60 // 上传分片请求默认超时时间
34+ UPLOAD_RETRY_COUNT = 3
35+ UPLOAD_RETRY_WAIT_TIME = time .Second * 1
36+ UPLOAD_RETRY_MAX_WAIT_TIME = time .Second * 5
3637)
3738
3839var config = driver.Config {
You can’t perform that action at this time.
0 commit comments