refactor: improve upload handling (#1455)

* fix(quark): refactor upPart to use http.NewRequest

* fix(quark): improved upload handling

* fix(quark_open): improved upload handling

* fix: add retry context to multiple upload functions

* fix: optimize hash calculation in multipart upload to avoid blocking

* fix: update error handling in lifecycle functions for better clarity

* fix: update upload progress calculation to improve accuracy

* fix: simplify error handling in lifecycle functions for improved readability

* fix: remove unnecessary mutex for part uploads to simplify code

* fix(stream): simplify file handling in NewStreamSectionReader and improve error messages

* fix(terabox): optimize chunk count calculation in Put method

* perf(chaoxing): 表单上传文件0拷贝

* fix(cnb_releases): improve file upload progress tracking

* fix(baidu_netdisk): improve upload handling

* fix(upload): optimize buffer initialization for file uploads

* fix(baidu_netdisk): add retry condition to skip ErrUploadIDExpired in upload loop
This commit is contained in:
j2rong4cn
2025-11-27 19:34:03 +08:00
committed by GitHub
parent 1f373eac8d
commit 9835afc645
27 changed files with 316 additions and 342 deletions

View File

@@ -29,6 +29,7 @@ func NewGroupWithContext(ctx context.Context, limit int, retryOpts ...retry.Opti
}
// OrderedGroup
// 使得Lifecycle.Before是有序且线程安全
func NewOrderedGroupWithContext(ctx context.Context, limit int, retryOpts ...retry.Option) (*Group, context.Context) {
group, ctx := NewGroupWithContext(ctx, limit, retryOpts...)
group.startChan = make(chan token, 1)
@@ -53,11 +54,11 @@ func (g *Group) Go(do func(ctx context.Context) error) {
}
type Lifecycle struct {
// Before在OrderedGroup是线程安全的
// Before在OrderedGroup是有序且线程安全的
// 只会被调用一次
Before func(ctx context.Context) error
Before func(ctx context.Context) (err error)
// 如果Before返回err就不调用Do
Do func(ctx context.Context) error
Do func(ctx context.Context) (err error)
// 最后调用一次After
After func(err error)
}