Compare commits

...

20 Commits

Author SHA1 Message Date
101f4a2434 Merge remote-tracking branch 'upstream/main' into deps/resty-v3 2025-07-04 14:30:40 +08:00
4990af3c09 fix 139yun 2025-07-04 14:27:10 +08:00
f3920b02f7 fix(net): goroutine deadlock 2025-07-04 12:52:21 +08:00
2ec9dad3db fix(deps): update module github.com/charmbracelet/lipgloss to v0.13.1 (#449)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-04 12:16:42 +08:00
e11227fe2d fix(deps): update module github.com/otiai10/copy to v1.14.1 (#530)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-04 12:16:25 +08:00
859931b78c fix(deps): update module github.com/nwaples/rardecode/v2 to v2.1.1 (#529)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-04 11:27:14 +08:00
b591524ac3 fix(deps): update module github.com/dlclark/regexp2 to v1.11.5 (#450)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-04 11:26:53 +08:00
dc26b4fce5 fix(deps): update module github.com/aws/aws-sdk-go to v1.55.7 (#439)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-04 11:26:36 +08:00
f8cf02a2da fix(deps): update module github.com/golang-jwt/jwt/v4 to v4.5.2 (#453)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-04 11:26:11 +08:00
a214e794f4 fix(deps): update module github.com/ncw/swift/v2 to v2.0.4 (#525)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-04 11:25:52 +08:00
54d761b371 fix(deps): update module github.com/gin-contrib/cors to v1.7.6 (#451)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-04 11:20:51 +08:00
82619cc9b2 chore(mopan,weiyun): resty update 2025-07-03 22:36:56 +08:00
9b69d8e3c4 115 2025-07-03 21:37:24 +08:00
a73b345749 chore(deps): use resty.dev/v3 2025-07-03 21:19:55 +08:00
bea7a9b0e4 chore: remove deprecated trainbit drive (#563)
* chore: remove deprecated trainbit drive

* chore: go mod tidy

---------

Co-authored-by: j2rong4cn <j2rong@qq.com>
2025-07-03 18:30:37 +08:00
a46f4cff18 chore(pr auto reply ci): Update PR title validation and feedback messages (#559)
Update PR title validation and feedback messages

Improves the PR title regex to be non-greedy and adds 'chore' to the allowed prefixes. Enhances feedback comments with clearer instructions in both Chinese and English, including guidance for PRs spanning multiple components.
2025-07-03 15:33:02 +08:00
8eb2d600c7 chore(issues): issue and pr auto reply (#551) 2025-07-03 13:11:39 +08:00
ffb6c2a180 refactor: optimize stream, link, and resource management (#486)
* refactor: optimize stream, link, and resource management

* Link.MFile改为io.ReadSeeker类型

* fix (crypt): read on closed response body

* chore

* chore

* chore
2025-07-03 10:39:34 +08:00
8e19a0fb07 fix(s3): logic bug (close #547 #548) 2025-07-03 10:36:34 +08:00
79f4f96217 feat(strm):add sign and encode path options (#537) 2025-07-02 21:09:57 +08:00
142 changed files with 662 additions and 1036 deletions

21
.github/config.yml vendored
View File

@ -1,21 +0,0 @@
# Configuration for welcome - https://github.com/behaviorbot/welcome
# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome
# Comment to be posted to on first time issues
newIssueWelcomeComment: >
Thanks for opening your first issue here! Be sure to follow the issue template!
# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome
# Comment to be posted to on PRs from first time contributors in your repository
newPRWelcomeComment: >
Thanks for opening this pull request! Please check out our contributing guidelines.
# Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge
# Comment to be posted to on pull requests merged by a first time user
firstPRMergeComment: >
Congrats on merging your first pull request! We here at behavior bot are proud of you!
# It is recommend to include as many gifs and emojis as possible

21
.github/stale.yml vendored
View File

@ -1,21 +0,0 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 44
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 20
# Issues with these labels will never be considered stale
exemptLabels:
- accepted
- security
- working
- pr-welcome
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: >
This issue was closed due to inactive more than 52 days. You can reopen or
recreate it if you think it should continue. Thank you for your contributions again.

61
.github/workflows/issue_pr_comment.yml vendored Normal file
View File

@ -0,0 +1,61 @@
name: Issue or PR Auto Reply
on:
issues:
types: [opened]
pull_request:
types: [opened]
permissions:
issues: write
pull-requests: write
jobs:
auto-reply:
runs-on: ubuntu-latest
if: github.event_name == 'issues'
steps:
- name: Check issue for unchecked tasks and reply
uses: actions/github-script@v7
with:
script: |
const issueBody = context.payload.issue.body || "";
const unchecked = /- \[ \] /.test(issueBody);
let comment = "感谢您联系OpenList。我们会尽快回复您。\n";
comment += "Thanks for contacting OpenList. We will reply to you as soon as possible.\n\n";
if (unchecked) {
comment += "由于您提出的 Issue 中包含部分未确认的项目,为了更好地管理项目,在人工审核后可能会直接关闭此问题。\n";
comment += "如果您能确认并补充相关未确认项目的信息,欢迎随时重新提交。我们会及时关注并处理。感谢您的理解与支持!\n";
comment += "Since your issue contains some unchecked tasks, it may be closed after manual review.\n";
comment += "If you can confirm and provide information for the unchecked tasks, feel free to resubmit.\n";
comment += "We will pay attention and handle it in a timely manner.\n\n";
comment += "感谢您的理解与支持!\n";
comment += "Thank you for your understanding and support!\n";
}
await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: comment
});
pr-title-check:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Check PR title for required prefix and comment
uses: actions/github-script@v7
with:
script: |
const title = context.payload.pull_request.title || "";
const ok = /^(feat|docs|fix|style|refactor|chore)\(.+?\): /i.test(title);
if (!ok) {
let comment = "⚠️ PR 标题需以 `feat(): `, `docs(): `, `fix(): `, `style(): `, `refactor(): `, `chore(): ` 其中之一开头,例如:`feat(component): 新增功能`。\n";
comment += "⚠️ The PR title must start with `feat(): `, `docs(): `, `fix(): `, `style(): `, or `refactor(): `, `chore(): `. For example: `feat(component): add new feature`.\n\n";
comment += "如果跨多个组件,请使用主要组件作为前缀,并在标题中枚举、描述中说明。\n";
comment += "If it spans multiple components, use the main component as the prefix and enumerate in the title, describe in the body.\n\n";
await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: comment
});
}

View File

@ -9,7 +9,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/internal/setting"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func DelAdminCacheOnline() {
@ -42,8 +42,8 @@ func DelUserCacheOnline(username string) {
utils.Log.Warnf("[del_user_cache_online] failed: %+v", res.String())
return
}
code := utils.Json.Get(res.Body(), "code").ToInt()
msg := utils.Json.Get(res.Body(), "message").ToString()
code := utils.Json.Get(res.Bytes(), "code").ToInt()
msg := utils.Json.Get(res.Bytes(), "message").ToString()
if code != 200 {
utils.Log.Errorf("[del_user_cache_online] error: %s", msg)
return

View File

@ -2,7 +2,7 @@ package _115
import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
log "github.com/sirupsen/logrus"
)

View File

@ -10,7 +10,7 @@ import (
streamPkg "github.com/OpenListTeam/OpenList/v4/internal/stream"
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
"github.com/pkg/errors"
"golang.org/x/time/rate"
)
@ -93,7 +93,7 @@ func (d *Pan115) MakeDir(ctx context.Context, parentDir model.Obj, dirName strin
req := d.client.NewRequest().
SetFormData(form).
SetResult(&result).
ForceContentType("application/json;charset=UTF-8")
SetForceResponseContentType("application/json;charset=UTF-8")
resp, err := req.Post(driver115.ApiDirAdd)

View File

@ -5,7 +5,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/SheltonZhu/115driver/pkg/driver"
"github.com/j2rong4cn/115driver/pkg/driver"
)
var _ model.Obj = (*FileObj)(nil)

View File

@ -24,9 +24,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
cipher "github.com/SheltonZhu/115driver/pkg/crypto/ec115"
crypto "github.com/SheltonZhu/115driver/pkg/crypto/m115"
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
cipher "github.com/j2rong4cn/115driver/pkg/crypto/ec115"
crypto "github.com/j2rong4cn/115driver/pkg/crypto/m115"
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
"github.com/pkg/errors"
)
@ -88,7 +88,7 @@ func (d *Pan115) getNewFileByPickCode(pickCode string) (*FileObj, error) {
result := driver115.GetFileInfoResponse{}
req := d.client.NewRequest().
SetQueryParam("pick_code", pickCode).
ForceContentType("application/json;charset=UTF-8").
SetForceResponseContentType("application/json;charset=UTF-8").
SetResult(&result)
resp, err := req.Get(driver115.ApiFileInfo)
if err := driver115.CheckErr(err, &result, resp); err != nil {
@ -125,7 +125,7 @@ func (d *Pan115) DownloadWithUA(pickCode, ua string) (*driver115.DownloadInfo, e
req.Header.Set("Cookie", d.Cookie)
req.Header.Set("User-Agent", ua)
resp, err := d.client.Client.GetClient().Do(req)
resp, err := d.client.Client.Client().Do(req)
if err != nil {
return nil, err
}
@ -227,7 +227,7 @@ func (d *Pan115) rapidUpload(fileSize int64, fileName, dirID, preID, fileID stri
if err != nil {
return nil, err
}
data := resp.RawBody()
data := resp.Body
defer data.Close()
if bodyBytes, err = io.ReadAll(data); err != nil {
return nil, err

View File

@ -7,7 +7,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
"golang.org/x/time/rate"
)

View File

@ -7,7 +7,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
driver115 "github.com/SheltonZhu/115driver/pkg/driver"
driver115 "github.com/j2rong4cn/115driver/pkg/driver"
"github.com/pkg/errors"
)

View File

@ -22,8 +22,8 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type Pan123 struct {
@ -115,7 +115,7 @@ func (d *Pan123) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
if res.StatusCode() == 302 {
link.URL = res.Header().Get("location")
} else if res.StatusCode() < 300 {
link.URL = utils.Json.Get(res.Body(), "data", "redirect_url").ToString()
link.URL = utils.Json.Get(res.Bytes(), "data", "redirect_url").ToString()
}
link.Header = http.Header{
"Referer": []string{"https://www.123pan.com/"},

View File

@ -11,7 +11,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func (d *Pan123) getS3PreSignedUrls(ctx context.Context, upReq *UploadResp, start, end int) (*S3PreSignedURLs, error) {

View File

@ -15,9 +15,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -172,10 +172,10 @@ func (d *Pan123) login() error {
if err != nil {
return err
}
if utils.Json.Get(res.Body(), "code").ToInt() != 200 {
err = fmt.Errorf(utils.Json.Get(res.Body(), "message").ToString())
if utils.Json.Get(res.Bytes(), "code").ToInt() != 200 {
err = fmt.Errorf(utils.Json.Get(res.Bytes(), "message").ToString())
} else {
d.AccessToken = utils.Json.Get(res.Body(), "data", "token").ToString()
d.AccessToken = utils.Json.Get(res.Bytes(), "data", "token").ToString()
}
return err
}
@ -222,7 +222,7 @@ do:
if err != nil {
return nil, err
}
body := res.Body()
body := res.Bytes()
code := utils.Json.Get(body, "code").ToInt()
if code != 0 {
if !isRetry && code == 401 {

View File

@ -13,7 +13,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/avast/retry-go"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func (d *Open123) create(parentFileID int64, filename string, etag string, size int64, duplicate int, containDir bool) (*UploadCreateResp, error) {

View File

@ -9,8 +9,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
var ( //不同情况下获取的AccessTokenQPS限制不同 如下模块化易于拓展
@ -56,7 +56,7 @@ func (d *Open123) Request(apiInfo *ApiInfo, method string, callback base.ReqCall
if err != nil {
return nil, err
}
body := res.Body()
body := res.Bytes()
// 解析为通用响应
var baseResp BaseResp

View File

@ -17,8 +17,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type Pan123Share struct {
@ -119,7 +119,7 @@ func (d *Pan123Share) Link(ctx context.Context, file model.Obj, args model.LinkA
if res.StatusCode() == 302 {
link.URL = res.Header().Get("location")
} else if res.StatusCode() < 300 {
link.URL = utils.Json.Get(res.Body(), "data", "redirect_url").ToString()
link.URL = utils.Json.Get(res.Bytes(), "data", "redirect_url").ToString()
}
link.Header = http.Header{
"Referer": []string{"https://www.123pan.com/"},

View File

@ -15,8 +15,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
"resty.dev/v3"
)
const (
@ -76,7 +76,7 @@ func (d *Pan123Share) request(url string, method string, callback base.ReqCallba
if err != nil {
return nil, err
}
body := res.Body()
body := res.Bytes()
code := utils.Json.Get(body, "code").ToInt()
if code != 0 {
return nil, errors.New(jsoniter.Get(body, "message").ToString())

View File

@ -286,10 +286,8 @@ type PersonalUploadUrlResp struct {
}
type QueryRoutePolicyResp struct {
Success bool `json:"success"`
Code string `json:"code"`
Message string `json:"message"`
Data struct {
BaseResp
Data struct {
RoutePolicyList []struct {
SiteID string `json:"siteID"`
SiteCode string `json:"siteCode"`

View File

@ -17,9 +17,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/OpenList/v4/pkg/utils/random"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -89,7 +89,7 @@ func (d *Yun139) refreshToken() error {
var resp RefreshTokenResp
reqBody := "<root><token>" + splits[2] + "</token><account>" + splits[1] + "</account><clienttype>656</clienttype></root>"
_, err = base.RestyClient.R().
ForceContentType("application/xml").
SetForceResponseContentType("application/xml").
SetBody(reqBody).
SetResult(&resp).
Post(url)
@ -150,29 +150,24 @@ func (d *Yun139) request(pathname string, method string, callback base.ReqCallba
return nil, errors.New(e.Message)
}
if resp != nil {
err = utils.Json.Unmarshal(res.Body(), resp)
err = utils.Json.Unmarshal(res.Bytes(), resp)
if err != nil {
return nil, err
}
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Yun139) requestRoute(data interface{}, resp interface{}) ([]byte, error) {
body, err := utils.Json.Marshal(data)
if err != nil {
return nil, err
}
url := "https://user-njs.yun.139.com/user/route/qryRoutePolicy"
req := base.RestyClient.R()
randStr := random.String(16)
ts := time.Now().Format("2006-01-02 15:04:05")
callback := func(req *resty.Request) {
req.SetBody(data)
}
if callback != nil {
callback(req)
}
body, err := utils.Json.Marshal(req.Body)
if err != nil {
return nil, err
}
req.SetBody(data)
sign := calSign(string(body), ts, randStr)
svcType := "1"
if d.isFamily() {
@ -199,20 +194,24 @@ func (d *Yun139) requestRoute(data interface{}, resp interface{}) ([]byte, error
"Inner-Hcy-Router-Https": "1",
})
var e BaseResp
req.SetResult(&e)
res, err := req.Execute(http.MethodPost, url)
if err != nil {
return nil, err
}
log.Debugln(res.String())
var e BaseResp
err = utils.Json.Unmarshal(res.Bytes(), &e)
if err != nil {
return nil, err
}
if !e.Success {
return nil, errors.New(e.Message)
}
if resp != nil {
err = utils.Json.Unmarshal(res.Body(), resp)
if err != nil {
return nil, err
}
err = utils.Json.Unmarshal(res.Bytes(), resp)
if err != nil {
return nil, err
}
return res.Body(), nil
return res.Bytes(), err
}
func (d *Yun139) post(pathname string, data interface{}, resp interface{}) ([]byte, error) {
@ -500,12 +499,12 @@ func (d *Yun139) personalRequest(pathname string, method string, callback base.R
return nil, errors.New(e.Message)
}
if resp != nil {
err = utils.Json.Unmarshal(res.Body(), resp)
err = utils.Json.Unmarshal(res.Bytes(), resp)
if err != nil {
return nil, err
}
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Yun139) personalPost(pathname string, data interface{}, resp interface{}) ([]byte, error) {
return d.personalRequest(pathname, http.MethodPost, func(req *resty.Request) {

View File

@ -9,8 +9,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type Cloud189 struct {
@ -52,7 +52,7 @@ func (d *Cloud189) Link(ctx context.Context, file model.Obj, args model.LinkArgs
if err != nil {
return nil, err
}
client := resty.NewWithClient(d.client.GetClient()).SetRedirectPolicy(
client := resty.NewWithClient(d.client.Client()).SetRedirectPolicy(
resty.RedirectPolicyFunc(func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
}))

View File

@ -83,7 +83,7 @@ func (d *Cloud189) newLogin() error {
if err != nil {
return err
}
err = utils.Json.Unmarshal(res.Body(), &encryptConf)
err = utils.Json.Unmarshal(res.Bytes(), &encryptConf)
if err != nil {
return err
}
@ -118,9 +118,9 @@ func (d *Cloud189) newLogin() error {
return err
}
log.Debugf("189 login resp body: %s", res.String())
loginResult := utils.Json.Get(res.Body(), "result").ToInt()
loginResult := utils.Json.Get(res.Bytes(), "result").ToInt()
if loginResult != 0 {
return errors.New(utils.Json.Get(res.Body(), "msg").ToString())
return errors.New(utils.Json.Get(res.Bytes(), "msg").ToString())
}
return nil
}

View File

@ -20,9 +20,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
myrand "github.com/OpenListTeam/OpenList/v4/pkg/utils/random"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -81,7 +81,7 @@ import (
// // Enter the verification code manually
// //err = message.GetMessenger().WaitSend(message.Message{
// // Type: "image",
// // Content: "data:image/png;base64," + base64.StdEncoding.EncodeToString(imgRes.Body()),
// // Content: "data:image/png;base64," + base64.StdEncoding.EncodeToString(imgRes.Body),
// //}, 10)
// //if err != nil {
// // return err
@ -89,15 +89,15 @@ import (
// //vCodeRS, err = message.GetMessenger().WaitReceive(30)
// // use ocr api
// vRes, err := base.RestyClient.R().SetMultipartField(
// "image", "validateCode.png", "image/png", bytes.NewReader(imgRes.Body())).
// "image", "validateCode.png", "image/png", bytes.NewReader(imgRes.Body)).
// Post(setting.GetStr(conf.OcrApi))
// if err != nil {
// return err
// }
// if jsoniter.Get(vRes.Body(), "status").ToInt() != 200 {
// return errors.New("ocr error:" + jsoniter.Get(vRes.Body(), "msg").ToString())
// if jsoniter.Get(vRes.Bytes(), "status").ToInt() != 200 {
// return errors.New("ocr error:" + jsoniter.Get(vRes.Bytes(), "msg").ToString())
// }
// vCodeRS = jsoniter.Get(vRes.Body(), "result").ToString()
// vCodeRS = jsoniter.Get(vRes.Bytes(), "result").ToString()
// log.Debugln("code: ", vCodeRS)
// }
// userRsa := RsaEncode([]byte(d.Username), jRsakey, true)
@ -128,7 +128,7 @@ import (
// if err != nil {
// return err
// }
// err = utils.Json.Unmarshal(res.Body(), &loginResp)
// err = utils.Json.Unmarshal(res.Bytes(), &loginResp)
// if err != nil {
// log.Error(err.Error())
// return err
@ -167,10 +167,10 @@ func (d *Cloud189) request(url string, method string, callback base.ReqCallback,
return d.request(url, method, callback, resp)
}
}
if jsoniter.Get(res.Body(), "res_code").ToInt() != 0 {
err = errors.New(jsoniter.Get(res.Body(), "res_message").ToString())
if jsoniter.Get(res.Bytes(), "res_code").ToInt() != 0 {
err = errors.New(jsoniter.Get(res.Bytes(), "res_message").ToString())
}
return res.Body(), err
return res.Bytes(), err
}
func (d *Cloud189) getFiles(fileId string) ([]model.Obj, error) {
@ -232,7 +232,7 @@ func (d *Cloud189) oldUpload(dstDir model.Obj, file model.FileStreamer) error {
if err != nil {
return err
}
if utils.Json.Get(res.Body(), "MD5").ToString() != "" {
if utils.Json.Get(res.Bytes(), "MD5").ToString() != "" {
return nil
}
log.Debugf(res.String())
@ -297,7 +297,7 @@ func (d *Cloud189) uploadRequest(uri string, form map[string]string, resp interf
if err != nil {
return nil, err
}
data = res.Body()
data = res.Bytes()
if utils.Json.Get(data, "code").ToString() != "SUCCESS" {
return nil, errors.New(uri + "---" + jsoniter.Get(data, "msg").ToString())
}

View File

@ -12,7 +12,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type Cloud189TV struct {
@ -126,7 +126,7 @@ func (y *Cloud189TV) Link(ctx context.Context, file model.Obj, args model.LinkAr
if err != nil {
return nil, err
}
defer res.RawBody().Close()
defer res.Body.Close()
if res.StatusCode() == 302 {
downloadUrl.URL = res.Header().Get("location")
}

View File

@ -5,23 +5,24 @@ import (
"encoding/base64"
"encoding/xml"
"fmt"
"github.com/skip2/go-qrcode"
"io"
"net/http"
"strconv"
"strings"
"time"
"github.com/skip2/go-qrcode"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors"
"resty.dev/v3"
)
const (
@ -96,7 +97,7 @@ func (y *Cloud189TV) request(url, method string, callback base.ReqCallback, para
if erron.HasError() {
return nil, &erron
}
return res.Body(), nil
return res.Bytes(), nil
}
func (y *Cloud189TV) get(url string, callback base.ReqCallback, resp interface{}, isFamily ...bool) ([]byte, error) {

View File

@ -13,8 +13,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
"resty.dev/v3"
)
type Cloud189PC struct {
@ -171,7 +171,7 @@ func (y *Cloud189PC) Link(ctx context.Context, file model.Obj, args model.LinkAr
if err != nil {
return nil, err
}
defer res.RawBody().Close()
defer res.Body.Close()
if res.StatusCode() == 302 {
downloadUrl.URL = res.Header().Get("location")
}

View File

@ -30,10 +30,10 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/avast/retry-go"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors"
"resty.dev/v3"
)
const (
@ -129,7 +129,7 @@ func (y *Cloud189PC) request(url, method string, callback base.ReqCallback, para
if erron.HasError() {
return nil, &erron
}
return res.Body(), nil
return res.Bytes(), nil
}
func (y *Cloud189PC) get(url string, callback base.ReqCallback, resp interface{}, isFamily ...bool) ([]byte, error) {
@ -287,7 +287,7 @@ func (y *Cloud189PC) login() (err error) {
param := y.loginParam
var loginresp LoginResp
_, err = y.client.R().
ForceContentType("application/json;charset=UTF-8").SetResult(&loginresp).
SetForceResponseContentType("application/json;charset=UTF-8").SetResult(&loginresp).
SetHeaders(map[string]string{
"REQID": param.ReqId,
"lt": param.Lt,
@ -370,7 +370,7 @@ func (y *Cloud189PC) initLoginParam() error {
// 获取rsa公钥
var encryptConf EncryptConfResp
_, err = y.client.R().
ForceContentType("application/json;charset=UTF-8").SetResult(&encryptConf).
SetForceResponseContentType("application/json;charset=UTF-8").SetResult(&encryptConf).
SetFormData(map[string]string{"appId": APP_ID}).
Post(AUTH_URL + "/api/logbox/config/encryptConf.do")
if err != nil {
@ -411,19 +411,19 @@ func (y *Cloud189PC) initLoginParam() error {
if imgRes.Size() > 20 {
if setting.GetStr(conf.OcrApi) != "" && !y.NoUseOcr {
vRes, err := base.RestyClient.R().
SetMultipartField("image", "validateCode.png", "image/png", bytes.NewReader(imgRes.Body())).
SetMultipartField("image", "validateCode.png", "image/png", bytes.NewReader(imgRes.Bytes())).
Post(setting.GetStr(conf.OcrApi))
if err != nil {
return err
}
if jsoniter.Get(vRes.Body(), "status").ToInt() == 200 {
y.VCode = jsoniter.Get(vRes.Body(), "result").ToString()
if jsoniter.Get(vRes.Bytes(), "status").ToInt() == 200 {
y.VCode = jsoniter.Get(vRes.Bytes(), "result").ToString()
return nil
}
}
// 返回验证码图片给前端
return fmt.Errorf(`need img validate code: <img src="data:image/png;base64,%s"/>`, base64.StdEncoding.EncodeToString(imgRes.Body()))
return fmt.Errorf(`need img validate code: <img src="data:image/png;base64,%s"/>`, base64.StdEncoding.EncodeToString(imgRes.Bytes()))
}
return nil
}

View File

@ -113,6 +113,7 @@ func (d *Alias) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
for _, dst := range dsts {
link, err := d.link(ctx, dst, sub, args)
if err == nil {
link.Expiration = nil // 去除非必要缓存d.link里op.Lin有缓存
if !args.Redirect && len(link.URL) > 0 {
// 正常情况下 多并发 仅支持返回URL的驱动
// alias套娃alias 可以让crypt、mega等驱动(不返回URL的) 支持并发

View File

@ -22,8 +22,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/stream"
"github.com/OpenListTeam/OpenList/v4/pkg/cron"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type AliDrive struct {

View File

@ -11,8 +11,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/dustinxie/ecc"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
"resty.dev/v3"
)
func (d *AliDrive) createSession() error {
@ -62,7 +62,7 @@ func (d *AliDrive) refreshToken() error {
var resp base.TokenResp
var e RespErr
_, err := base.RestyClient.R().
//ForceContentType("application/json").
//SetForceResponseContentType("application/json").
SetBody(base.Json{"refresh_token": d.RefreshToken, "grant_type": "refresh_token"}).
SetResult(&resp).
SetError(&e).
@ -134,7 +134,7 @@ func (d *AliDrive) request(url, method string, callback base.ReqCallback, resp i
} else if res.IsError() {
return nil, errors.New("bad status code " + res.Status()), e
}
return res.Body(), nil, e
return res.Bytes(), nil, e
}
func (d *AliDrive) getFiles(fileId string) ([]File, error) {

View File

@ -14,8 +14,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/rateg"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type AliyundriveOpen struct {

View File

@ -18,8 +18,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/avast/retry-go"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
func makePartInfos(size int) []base.Json {

View File

@ -13,8 +13,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -56,7 +56,7 @@ func (d *AliyundriveOpen) _refreshToken() (string, string, error) {
//var resp base.TokenResp
var e ErrResp
res, err := base.RestyClient.R().
//ForceContentType("application/json").
//SetForceResponseContentType("application/json").
SetBody(base.Json{
"client_id": d.ClientID,
"client_secret": d.ClientSecret,
@ -73,7 +73,7 @@ func (d *AliyundriveOpen) _refreshToken() (string, string, error) {
if e.Code != "" {
return "", "", fmt.Errorf("failed to refresh token: %s", e.Message)
}
refresh, access := utils.Json.Get(res.Body(), "refresh_token").ToString(), utils.Json.Get(res.Body(), "access_token").ToString()
refresh, access := utils.Json.Get(res.Bytes(), "refresh_token").ToString(), utils.Json.Get(res.Bytes(), "access_token").ToString()
if refresh == "" {
return "", "", fmt.Errorf("failed to refresh token: refresh token is empty, resp: %s", res.String())
}
@ -160,7 +160,7 @@ func (d *AliyundriveOpen) requestReturnErrResp(uri, method string, callback base
}
return nil, fmt.Errorf("%s:%s", e.Code, e.Message), &e
}
return res.Body(), nil, nil
return res.Bytes(), nil, nil
}
func (d *AliyundriveOpen) list(ctx context.Context, data base.Json) (*Files, error) {

View File

@ -13,8 +13,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/cron"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/rateg"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type AliyundriveShare struct {

View File

@ -90,7 +90,7 @@ func (d *AliyundriveShare) request(url, method string, callback base.ReqCallback
return nil, errors.New(e.Code + ": " + e.Message)
}
}
return resp.Body(), nil
return resp.Bytes(), nil
}
func (d *AliyundriveShare) getFiles(fileId string) ([]File, error) {

View File

@ -63,7 +63,6 @@ import (
_ "github.com/OpenListTeam/OpenList/v4/drivers/thunder"
_ "github.com/OpenListTeam/OpenList/v4/drivers/thunder_browser"
_ "github.com/OpenListTeam/OpenList/v4/drivers/thunderx"
_ "github.com/OpenListTeam/OpenList/v4/drivers/trainbit"
_ "github.com/OpenListTeam/OpenList/v4/drivers/url_tree"
_ "github.com/OpenListTeam/OpenList/v4/drivers/uss"
_ "github.com/OpenListTeam/OpenList/v4/drivers/virtual"

View File

@ -355,8 +355,8 @@ func (d *BaiduNetdisk) uploadSlice(ctx context.Context, params map[string]string
return err
}
log.Debugln(res.RawResponse.Status + res.String())
errCode := utils.Json.Get(res.Body(), "error_code").ToInt()
errNo := utils.Json.Get(res.Body(), "errno").ToInt()
errCode := utils.Json.Get(res.Bytes(), "error_code").ToInt()
errNo := utils.Json.Get(res.Bytes(), "errno").ToInt()
if errCode != 0 || errNo != 0 {
return errs.NewErr(errs.StreamIncomplete, "error in uploading to baidu, will retry. response=%s", res.String())
}

View File

@ -16,8 +16,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/avast/retry-go"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -110,7 +110,7 @@ func (d *BaiduNetdisk) request(furl string, method string, callback base.ReqCall
return err
}
log.Debugf("[baidu_netdisk] req: %s, resp: %s", furl, res.String())
errno := utils.Json.Get(res.Body(), "errno").ToInt()
errno := utils.Json.Get(res.Bytes(), "errno").ToInt()
if errno != 0 {
if utils.SliceContains([]int{111, -6}, errno) {
log.Info("refreshing baidu_netdisk token.")
@ -121,13 +121,13 @@ func (d *BaiduNetdisk) request(furl string, method string, callback base.ReqCall
}
if 31023 == errno && d.DownloadAPI == "crack_video" {
result = res.Body()
result = res.Bytes()
return nil
}
return fmt.Errorf("req: [%s] ,errno: %d, refer to https://pan.baidu.com/union/doc/", furl, errno)
}
result = res.Body()
result = res.Bytes()
return nil
},
retry.LastErrorOnly(true),

View File

@ -21,7 +21,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/errgroup"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/avast/retry-go"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type BaiduPhoto struct {

View File

@ -12,7 +12,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
const (
@ -38,7 +38,7 @@ func (d *BaiduPhoto) Request(client *resty.Client, furl string, method string, c
return nil, err
}
erron := utils.Json.Get(res.Body(), "errno").ToInt()
erron := utils.Json.Get(res.Bytes(), "errno").ToInt()
switch erron {
case 0:
break
@ -63,7 +63,7 @@ func (d *BaiduPhoto) Request(client *resty.Client, furl string, method string, c
// if err != nil {
// return nil, err
// }
// return res.Body(), nil
// return res.Bytes(), nil
//}
// func (d *BaiduPhoto) refreshToken() error {

View File

@ -7,7 +7,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/conf"
"github.com/OpenListTeam/OpenList/v4/internal/net"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
var (
@ -34,7 +34,6 @@ func NewRestyClient() *resty.Client {
client := resty.New().
SetHeader("user-agent", UserAgent).
SetRetryCount(3).
SetRetryResetReaders(true).
SetTimeout(DefaultTimeout).
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: conf.Conf.TlsInsecureSkipVerify})
return client

View File

@ -1,6 +1,6 @@
package base
import "github.com/go-resty/resty/v2"
import "resty.dev/v3"
type Json map[string]interface{}

View File

@ -19,8 +19,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/cron"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"google.golang.org/appengine/log"
"resty.dev/v3"
)
type ChaoXing struct {

View File

@ -12,7 +12,7 @@ import (
"strings"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func (d *ChaoXing) requestDownload(pathname string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
@ -35,7 +35,7 @@ func (d *ChaoXing) requestDownload(pathname string, method string, callback base
if err != nil {
return nil, err
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *ChaoXing) request(pathname string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {
@ -61,7 +61,7 @@ func (d *ChaoXing) request(pathname string, method string, callback base.ReqCall
if err != nil {
return nil, err
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *ChaoXing) GetFiles(parent string) ([]File, error) {

View File

@ -12,7 +12,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type Cloudreve struct {

View File

@ -20,8 +20,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/setting"
"github.com/OpenListTeam/OpenList/v4/pkg/cookie"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -134,10 +134,10 @@ func (d *Cloudreve) doLogin(needCaptcha bool) error {
if err != nil {
return err
}
if jsoniter.Get(vRes.Body(), "status").ToInt() != 200 {
return errors.New("ocr error:" + jsoniter.Get(vRes.Body(), "msg").ToString())
if jsoniter.Get(vRes.Bytes(), "status").ToInt() != 200 {
return errors.New("ocr error:" + jsoniter.Get(vRes.Bytes(), "msg").ToString())
}
captchaCode = jsoniter.Get(vRes.Body(), "result").ToString()
captchaCode = jsoniter.Get(vRes.Bytes(), "result").ToString()
}
var resp Resp
err = d.request(http.MethodPost, loginPath, func(req *resty.Request) {
@ -206,7 +206,7 @@ func (d *Cloudreve) upLocal(ctx context.Context, stream model.FileStreamer, u Up
req.SetHeader("Content-Length", strconv.FormatInt(byteSize, 10))
req.SetHeader("User-Agent", d.getUA())
req.SetBody(driver.NewLimitedUploadStream(ctx, bytes.NewReader(byteData)))
req.AddRetryCondition(func(r *resty.Response, err error) bool {
req.AddRetryConditions(func(r *resty.Response, err error) bool {
if err != nil {
return true
}
@ -214,7 +214,7 @@ func (d *Cloudreve) upLocal(ctx context.Context, stream model.FileStreamer, u Up
return true
}
var retryResp Resp
jErr := base.RestyClient.JSONUnmarshal(r.Body(), &retryResp)
jErr := utils.Json.Unmarshal(r.Bytes(), &retryResp)
if jErr != nil {
return true
}

View File

@ -14,7 +14,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type CloudreveV4 struct {

View File

@ -20,8 +20,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/internal/setting"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -153,10 +153,10 @@ func (d *CloudreveV4) doLogin(needCaptcha bool) error {
if err != nil {
return err
}
if jsoniter.Get(vRes.Body(), "status").ToInt() != 200 {
return errors.New("ocr error:" + jsoniter.Get(vRes.Body(), "msg").ToString())
if jsoniter.Get(vRes.Bytes(), "status").ToInt() != 200 {
return errors.New("ocr error:" + jsoniter.Get(vRes.Bytes(), "msg").ToString())
}
captchaCode := jsoniter.Get(vRes.Body(), "result").ToString()
captchaCode := jsoniter.Get(vRes.Bytes(), "result").ToString()
if captchaCode == "" {
return errors.New("ocr error: empty result")
}
@ -224,7 +224,7 @@ func (d *CloudreveV4) upLocal(ctx context.Context, file model.FileStreamer, u Fi
req.SetContentLength(true)
req.SetHeader("Content-Length", strconv.FormatInt(byteSize, 10))
req.SetBody(driver.NewLimitedUploadStream(ctx, bytes.NewReader(byteData)))
req.AddRetryCondition(func(r *resty.Response, err error) bool {
req.AddRetryConditions(func(r *resty.Response, err error) bool {
if err != nil {
return true
}
@ -232,7 +232,7 @@ func (d *CloudreveV4) upLocal(ctx context.Context, file model.FileStreamer, u Fi
return true
}
var retryResp Resp
jErr := base.RestyClient.JSONUnmarshal(r.Body(), &retryResp)
jErr := utils.Json.Unmarshal(r.Bytes(), &retryResp)
if jErr != nil {
return true
}

View File

@ -254,43 +254,46 @@ func (d *Crypt) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
if remoteLink.RangeReadCloser == nil && remoteLink.MFile == nil && len(remoteLink.URL) == 0 {
return nil, fmt.Errorf("the remote storage driver need to be enhanced to support encrytion")
}
resultRangeReadCloser := &model.RangeReadCloser{}
resultRangeReadCloser.TryAdd(remoteLink.MFile)
if remoteLink.RangeReadCloser != nil {
resultRangeReadCloser.AddClosers(remoteLink.RangeReadCloser.GetClosers())
}
remoteFileSize := remoteFile.GetSize()
remoteClosers := utils.EmptyClosers()
rangeReaderFunc := func(ctx context.Context, underlyingOffset, underlyingLength int64) (io.ReadCloser, error) {
length := underlyingLength
if underlyingLength >= 0 && underlyingOffset+underlyingLength >= remoteFileSize {
length = -1
}
rrc := remoteLink.RangeReadCloser
if len(remoteLink.URL) > 0 {
var converted, err = stream.GetRangeReadCloserFromLink(remoteFileSize, remoteLink)
if err != nil {
return nil, err
}
rrc = converted
}
if rrc != nil {
remoteReader, err := rrc.RangeRead(ctx, http_range.Range{Start: underlyingOffset, Length: length})
remoteClosers.AddClosers(rrc.GetClosers())
if err != nil {
return nil, err
}
return remoteReader, nil
}
if remoteLink.MFile != nil {
_, err := remoteLink.MFile.Seek(underlyingOffset, io.SeekStart)
if err != nil {
return nil, err
}
//keep reuse same MFile and close at last.
remoteClosers.Add(remoteLink.MFile)
return io.NopCloser(remoteLink.MFile), nil
}
rrc := remoteLink.RangeReadCloser
if rrc == nil && len(remoteLink.URL) > 0 {
var err error
rrc, err = stream.GetRangeReadCloserFromLink(remoteFileSize, remoteLink)
if err != nil {
return nil, err
}
resultRangeReadCloser.AddClosers(rrc.GetClosers())
remoteLink.RangeReadCloser = rrc
}
if rrc != nil {
remoteReader, err := rrc.RangeRead(ctx, http_range.Range{Start: underlyingOffset, Length: length})
if err != nil {
return nil, err
}
return remoteReader, nil
}
return nil, errs.NotSupport
}
resultRangeReader := func(ctx context.Context, httpRange http_range.Range) (io.ReadCloser, error) {
resultRangeReadCloser.RangeReader = func(ctx context.Context, httpRange http_range.Range) (io.ReadCloser, error) {
readSeeker, err := d.cipher.DecryptDataSeek(ctx, rangeReaderFunc, httpRange.Start, httpRange.Length)
if err != nil {
return nil, err
@ -298,14 +301,9 @@ func (d *Crypt) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
return readSeeker, nil
}
resultRangeReadCloser := &model.RangeReadCloser{RangeReader: resultRangeReader, Closers: remoteClosers}
resultLink := &model.Link{
return &model.Link{
RangeReadCloser: resultRangeReadCloser,
Expiration: remoteLink.Expiration,
}
return resultLink, nil
}, nil
}
func (d *Crypt) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {

View File

@ -13,8 +13,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
"resty.dev/v3"
)
type Doubao struct {

View File

@ -27,9 +27,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/errgroup"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/avast/retry-go"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
const (
@ -83,7 +83,7 @@ func (d *Doubao) request(path string, method string, callback base.ReqCallback,
return nil, err
}
body := res.Body()
body := res.Bytes()
// 先解析为通用响应
if err = json.Unmarshal(body, &commonResp); err != nil {
return nil, err
@ -205,7 +205,7 @@ func (d *Doubao) signRequest(req *resty.Request, method, tokenType, uploadUrl st
}
// 查询参数按照字母顺序排序
canonicalQueryString := getCanonicalQueryString(req.QueryParam)
canonicalQueryString := getCanonicalQueryString(req.QueryParams)
// 规范请求头
canonicalHeaders, signedHeaders := getCanonicalHeadersFromMap(req.Header)
canonicalRequest := method + "\n" +
@ -270,7 +270,7 @@ func (d *Doubao) requestApi(url, method, tokenType string, callback base.ReqCall
return nil, err
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Doubao) initUploadToken() (*UploadToken, error) {
@ -524,7 +524,6 @@ func (d *Doubao) UploadByMultipart(ctx context.Context, config *UploadConfig, fi
if err != nil {
return nil, fmt.Errorf("failed to cache file: %w", err)
}
defer tempFile.Close()
up(10.0) // 更新进度
// 设置并行上传
threadG, uploadCtx := errgroup.NewGroupWithContext(ctx, d.uploadThread,
@ -656,7 +655,7 @@ func (d *Doubao) uploadRequest(uploadUrl string, method string, storeInfo StoreI
return nil, fmt.Errorf("upload request failed: %w", err)
}
return res.Body(), nil
return res.Bytes(), nil
}
// 初始化分片上传

View File

@ -10,7 +10,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type DoubaoShare struct {

View File

@ -12,8 +12,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
const (
@ -72,7 +72,7 @@ func (d *DoubaoShare) request(path string, method string, callback base.ReqCallb
return nil, err
}
body := res.Body()
body := res.Bytes()
// 先解析为通用响应
if err = json.Unmarshal(body, &commonResp); err != nil {
return nil, err

View File

@ -12,8 +12,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type Dropbox struct {

View File

@ -10,8 +10,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
func (d *Dropbox) refreshToken() error {
@ -49,7 +49,7 @@ func (d *Dropbox) refreshToken() error {
url := d.base + "/oauth2/token"
var tokenResp TokenResp
resp, err := base.RestyClient.R().
//ForceContentType("application/x-www-form-urlencoded").
//SetForceResponseContentType("application/x-www-form-urlencoded").
//SetBasicAuth(d.ClientID, d.ClientSecret).
SetFormData(map[string]string{
"grant_type": "refresh_token",
@ -112,7 +112,7 @@ func (d *Dropbox) request(uri, method string, callback base.ReqCallback, retry .
}
return nil, fmt.Errorf("%s:%s", e.Error, e.ErrorSummary)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Dropbox) list(ctx context.Context, data base.Json, isContinue bool) (*ListResp, error) {

View File

@ -9,7 +9,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func (d *FebBox) refreshTokenByOAuth2() error {
@ -48,9 +48,9 @@ func (d *FebBox) request(url string, method string, callback base.ReqCallback, r
switch e.ErrorCode {
case 0:
return res.Body(), nil
return res.Bytes(), nil
case 1:
return res.Body(), nil
return res.Bytes(), nil
case -10001:
if e.ServerName != "" {
// access_token 过期

View File

@ -7,6 +7,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/stream"
"github.com/jlaffaye/ftp"
)
@ -66,7 +67,11 @@ func (d *FTP) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*m
r := NewFileReader(d.conn, encode(file.GetPath(), d.Encoding), file.GetSize())
link := &model.Link{
MFile: r,
MFile: &stream.RateLimitFile{
File: r,
Limiter: stream.ServerDownloadLimit,
Ctx: ctx,
},
}
return link, nil
}

View File

@ -17,9 +17,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/ProtonMail/go-crypto/openpgp"
"github.com/go-resty/resty/v2"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type Github struct {
@ -680,7 +680,7 @@ func (d *Github) get(path string) (*Object, error) {
return nil, toErr(res)
}
var resp Object
err = utils.Json.Unmarshal(res.Body(), &resp)
err = utils.Json.Unmarshal(res.Bytes(), &resp)
return &resp, err
}
@ -780,7 +780,7 @@ func (d *Github) getTree(sha string) (*TreeResp, error) {
return nil, toErr(res)
}
var resp TreeResp
if err = utils.Json.Unmarshal(res.Body(), &resp); err != nil {
if err = utils.Json.Unmarshal(res.Bytes(), &resp); err != nil {
return nil, err
}
return &resp, nil
@ -818,7 +818,7 @@ func (d *Github) newTree(baseSha string, tree []interface{}) (string, error) {
return "", toErr(res)
}
var resp TreeResp
if err = utils.Json.Unmarshal(res.Body(), &resp); err != nil {
if err = utils.Json.Unmarshal(res.Bytes(), &resp); err != nil {
return "", err
}
return resp.Sha, nil
@ -847,7 +847,7 @@ func (d *Github) commit(message, treeSha string) error {
return toErr(res)
}
var resp CommitResp
if err = utils.Json.Unmarshal(res.Body(), &resp); err != nil {
if err = utils.Json.Unmarshal(res.Bytes(), &resp); err != nil {
return err
}
@ -876,7 +876,7 @@ func (d *Github) getBranchHead() (string, error) {
return "", toErr(res)
}
var resp BranchResp
if err = utils.Json.Unmarshal(res.Body(), &resp); err != nil {
if err = utils.Json.Unmarshal(res.Bytes(), &resp); err != nil {
return "", err
}
return resp.Commit.Sha, nil
@ -936,7 +936,7 @@ func (d *Github) getRepo() (*RepoResp, error) {
return nil, toErr(res)
}
var resp RepoResp
if err = utils.Json.Unmarshal(res.Body(), &resp); err != nil {
if err = utils.Json.Unmarshal(res.Bytes(), &resp); err != nil {
return nil, err
}
return &resp, nil
@ -951,7 +951,7 @@ func (d *Github) getAuthenticatedUser() (*UserResp, error) {
return nil, toErr(res)
}
resp := &UserResp{}
if err = utils.Json.Unmarshal(res.Body(), resp); err != nil {
if err = utils.Json.Unmarshal(res.Bytes(), resp); err != nil {
return nil, err
}
return resp, nil

View File

@ -13,7 +13,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/ProtonMail/go-crypto/openpgp"
"github.com/ProtonMail/go-crypto/openpgp/armor"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type MessageTemplateVars struct {
@ -40,7 +40,7 @@ func calculateBase64Length(inputLength int64) int64 {
func toErr(res *resty.Response) error {
var errMsg ErrResp
if err := utils.Json.Unmarshal(res.Body(), &errMsg); err != nil {
if err := utils.Json.Unmarshal(res.Bytes(), &errMsg); err != nil {
return errors.New(res.Status())
} else {
return fmt.Errorf("%s: %s", res.Status(), errMsg.Message)

View File

@ -6,7 +6,7 @@ import (
"time"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type MountPoint struct {
@ -26,7 +26,7 @@ func (m *MountPoint) RequestRelease(get func(url string) (*resty.Response, error
if m.Release == nil || refresh {
resp, _ := get("https://api.github.com/repos/" + m.Repo + "/releases/latest")
m.Release = new(Release)
json.Unmarshal(resp.Body(), m.Release)
json.Unmarshal(resp.Bytes(), m.Release)
}
}
@ -39,7 +39,7 @@ func (m *MountPoint) RequestReleases(get func(url string) (*resty.Response, erro
if m.Releases == nil || refresh {
resp, _ := get("https://api.github.com/repos/" + m.Repo + "/releases")
m.Releases = new([]Release)
json.Unmarshal(resp.Body(), m.Releases)
json.Unmarshal(resp.Bytes(), m.Releases)
}
}
@ -147,7 +147,7 @@ func (m *MountPoint) GetOtherFile(get func(url string) (*resty.Response, error),
if m.OtherFile == nil || refresh {
resp, _ := get("https://api.github.com/repos/" + m.Repo + "/contents")
m.OtherFile = new([]FileInfo)
json.Unmarshal(resp.Body(), m.OtherFile)
json.Unmarshal(resp.Bytes(), m.OtherFile)
}
files := make([]File, 0)

View File

@ -6,8 +6,8 @@ import (
"strings"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// 发送 GET 请求

View File

@ -11,7 +11,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type GoogleDrive struct {

View File

@ -17,9 +17,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"github.com/golang-jwt/jwt/v4"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -215,7 +215,7 @@ func (d *GoogleDrive) request(url string, method string, callback base.ReqCallba
}
return nil, fmt.Errorf("%s: %v", e.Error.Message, e.Error.Errors)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *GoogleDrive) getFiles(id string) ([]File, error) {

View File

@ -12,7 +12,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type GooglePhoto struct {

View File

@ -5,7 +5,7 @@ import (
"net/http"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -68,7 +68,7 @@ func (d *GooglePhoto) request(url string, method string, callback base.ReqCallba
}
return nil, fmt.Errorf("%s: %v", e.Error.Message, e.Error.Errors)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *GooglePhoto) getFiles(id string) ([]MediaItem, error) {

View File

@ -256,9 +256,6 @@ func (d *HalalCloud) getLink(ctx context.Context, file model.Obj, args model.Lin
if httpRange.Length >= 0 && httpRange.Start+httpRange.Length >= size {
length = -1
}
if err != nil {
return nil, fmt.Errorf("open download file failed: %w", err)
}
oo := &openObject{
ctx: ctx,
d: fileAddrs,

View File

@ -96,7 +96,3 @@ type SteamFile struct {
func (s *SteamFile) Read(p []byte) (n int, err error) {
return s.file.Read(p)
}
func (s *SteamFile) Close() error {
return s.file.Close()
}

View File

@ -19,8 +19,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/stream"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/foxxorcat/mopan-sdk-go"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type ILanZou struct {
@ -166,7 +166,7 @@ func (d *ILanZou) Link(ctx context.Context, file model.Obj, args model.LinkArgs)
if res.StatusCode() == 302 {
realURL = res.Header().Get("location")
} else {
return nil, fmt.Errorf("redirect failed, status: %d, msg: %s", res.StatusCode(), utils.Json.Get(res.Body(), "msg").ToString())
return nil, fmt.Errorf("redirect failed, status: %d, msg: %s", res.StatusCode(), utils.Json.Get(res.Bytes(), "msg").ToString())
}
link := model.Link{URL: realURL}
return &link, nil
@ -316,14 +316,14 @@ func (d *ILanZou) Put(ctx context.Context, dstDir model.Obj, s model.FileStreame
if err != nil {
return nil, err
}
token = utils.Json.Get(res.Body(), "token").ToString()
token = utils.Json.Get(res.Bytes(), "token").ToString()
} else {
keyBase64 := base64.URLEncoding.EncodeToString([]byte(key))
res, err := d.upClient.R().SetHeader("Authorization", "UpToken "+upToken).Post(fmt.Sprintf("https://upload.qiniup.com/buckets/%s/objects/%s/uploads", d.conf.bucket, keyBase64))
if err != nil {
return nil, err
}
uploadId := utils.Json.Get(res.Body(), "uploadId").ToString()
uploadId := utils.Json.Get(res.Bytes(), "uploadId").ToString()
parts := make([]Part, 0)
partNum := (s.GetSize() + DefaultPartSize - 1) / DefaultPartSize
for i := 1; i <= int(partNum); i++ {
@ -332,7 +332,7 @@ func (d *ILanZou) Put(ctx context.Context, dstDir model.Obj, s model.FileStreame
if err != nil {
return nil, err
}
etag := utils.Json.Get(res.Body(), "etag").ToString()
etag := utils.Json.Get(res.Bytes(), "etag").ToString()
parts = append(parts, Part{
PartNumber: i,
ETag: etag,
@ -345,7 +345,7 @@ func (d *ILanZou) Put(ctx context.Context, dstDir model.Obj, s model.FileStreame
if err != nil {
return nil, err
}
token = utils.Json.Get(res.Body(), "token").ToString()
token = utils.Json.Get(res.Bytes(), "token").ToString()
}
// commit upload
var resp UploadResultResp

View File

@ -12,8 +12,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/foxxorcat/mopan-sdk-go"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
func (d *ILanZou) login() error {
@ -92,7 +92,7 @@ func (d *ILanZou) request(pathname, method string, callback base.ReqCallback, pr
return nil, err
}
isRetry := len(retry) > 0 && retry[0]
body := res.Body()
body := res.Bytes()
code := utils.Json.Get(body, "code").ToInt()
msg := utils.Json.Get(body, "msg").ToString()
if code != 200 {

View File

@ -11,7 +11,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type KodBox struct {

View File

@ -6,7 +6,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func (d *KodBox) getToken() error {
@ -62,7 +62,7 @@ func (d *KodBox) request(method string, pathname string, callback base.ReqCallba
return nil, err
}
err := utils.Json.Unmarshal(res.Body(), &commonResp)
err := utils.Json.Unmarshal(res.Bytes(), &commonResp)
if err != nil {
return nil, err
}
@ -83,5 +83,5 @@ func (d *KodBox) request(method string, pathname string, callback base.ReqCallba
if commonResp.Code.(bool) == false {
return nil, fmt.Errorf("request failed: %s", commonResp.Data)
}
return res.Body(), nil
return res.Bytes(), nil
}

View File

@ -9,7 +9,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type LanZou struct {

View File

@ -16,8 +16,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
var upClient *resty.Client
@ -62,8 +62,8 @@ func (d *LanZou) post(url string, callback base.ReqCallback, resp interface{}) (
func (d *LanZou) _post(url string, callback base.ReqCallback, resp interface{}, up bool) ([]byte, error) {
data, err := d.request(url, http.MethodPost, func(req *resty.Request) {
req.AddRetryCondition(func(r *resty.Response, err error) bool {
if utils.Json.Get(r.Body(), "zt").ToInt() == 4 {
req.AddRetryConditions(func(r *resty.Response, err error) bool {
if utils.Json.Get(r.Bytes(), "zt").ToInt() == 4 {
time.Sleep(time.Second)
return true
}
@ -123,7 +123,7 @@ func (d *LanZou) request(url string, method string, callback base.ReqCallback, u
return nil, err
}
log.Debugf("lanzou request: url=>%s ,stats=>%d ,body => %s\n", res.Request.URL, res.StatusCode(), res.String())
return res.Body(), err
return res.Bytes(), err
}
func (d *LanZou) Login() ([]*http.Cookie, error) {
@ -141,8 +141,8 @@ func (d *LanZou) Login() ([]*http.Cookie, error) {
if err != nil {
return nil, err
}
if utils.Json.Get(resp.Body(), "zt").ToInt() != 1 {
return nil, fmt.Errorf("login err: %s", resp.Body())
if utils.Json.Get(resp.Bytes(), "zt").ToInt() != 1 {
return nil, fmt.Errorf("login err: %s", resp.Bytes())
}
d.Cookie = CookieToString(resp.Cookies())
return resp.Cookies(), nil

View File

@ -5,7 +5,7 @@ import (
"net/http"
"time"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/errs"

View File

@ -27,7 +27,7 @@ func (d *LenovoNasShare) request(url string, method string, callback base.ReqCal
if err != nil {
return nil, err
}
body := res.Body()
body := res.Bytes()
result := utils.Json.Get(body, "result").ToBool()
if !result {
return nil, errors.New(jsoniter.Get(body, "error", "msg").ToString())

View File

@ -242,7 +242,7 @@ func (d *Local) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
}
link.MFile = open
} else {
link.MFile = model.NewNopMFile(bytes.NewReader(buf.Bytes()))
link.MFile = bytes.NewReader(buf.Bytes())
//link.Header.Set("Content-Length", strconv.Itoa(buf.Len()))
}
} else {

View File

@ -18,9 +18,9 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type MediaTrack struct {
@ -184,9 +184,6 @@ func (d *MediaTrack) Put(ctx context.Context, dstDir model.Obj, file model.FileS
if err != nil {
return err
}
defer func() {
_ = tempFile.Close()
}()
uploader := s3manager.NewUploader(s)
if file.GetSize() > s3manager.MaxUploadParts*s3manager.DefaultUploadPartSize {
uploader.PartSize = file.GetSize() / (s3manager.MaxUploadParts - 1)

View File

@ -8,8 +8,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -31,9 +31,9 @@ func (d *MediaTrack) request(url string, method string, callback base.ReqCallbac
return nil, errors.New(e.Message)
}
if resp != nil {
err = utils.Json.Unmarshal(res.Body(), resp)
err = utils.Json.Unmarshal(res.Bytes(), resp)
}
return res.Body(), err
return res.Bytes(), err
}
func (d *MediaTrack) getFiles(parentId string) ([]File, error) {

View File

@ -6,7 +6,7 @@ import (
"io"
"time"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/driver"

View File

@ -143,9 +143,7 @@ func (d *MoPan) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
if err != nil {
return nil, err
}
defer func() {
_ = res.RawBody().Close()
}()
defer res.Body.Close()
if res.StatusCode() == 302 {
data.DownloadUrl = res.Header().Get("location")
}

View File

@ -2,7 +2,6 @@ package netease_music
import (
"context"
"io"
"net/http"
"strconv"
"strings"
@ -11,7 +10,6 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/sign"
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/OpenList/v4/pkg/utils/random"
"github.com/OpenListTeam/OpenList/v4/server/common"
@ -55,17 +53,8 @@ func (lrc *LyricObj) getProxyLink(ctx context.Context) *model.Link {
}
func (lrc *LyricObj) getLyricLink() *model.Link {
reader := strings.NewReader(lrc.lyric)
return &model.Link{
RangeReadCloser: &model.RangeReadCloser{
RangeReader: func(ctx context.Context, httpRange http_range.Range) (io.ReadCloser, error) {
if httpRange.Length < 0 {
return io.NopCloser(reader), nil
}
sr := io.NewSectionReader(reader, httpRange.Start, httpRange.Length)
return io.NopCloser(sr), nil
},
},
MFile: strings.NewReader(lrc.lyric),
}
}

View File

@ -79,7 +79,7 @@ func (d *NeteaseMusic) request(url, method string, opt ReqOption) ([]byte, error
if err != nil {
return nil, err
}
return res.Body(), nil
return res.Bytes(), nil
}
if method == http.MethodGet {
@ -87,7 +87,7 @@ func (d *NeteaseMusic) request(url, method string, opt ReqOption) ([]byte, error
if err != nil {
return nil, err
}
return res.Body(), nil
return res.Bytes(), nil
}
return nil, errs.NotImplement

View File

@ -13,7 +13,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type Onedrive struct {

View File

@ -16,8 +16,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
"resty.dev/v3"
)
var onedriveHostMap = map[string]Host{
@ -157,7 +157,7 @@ func (d *Onedrive) Request(url string, method string, callback base.ReqCallback,
}
return nil, errors.New(e.Error.Message)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Onedrive) getFiles(path string) ([]File, error) {

View File

@ -13,7 +13,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type OnedriveAPP struct {

View File

@ -16,8 +16,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
"resty.dev/v3"
)
var onedriveHostMap = map[string]Host{
@ -112,7 +112,7 @@ func (d *OnedriveAPP) Request(url string, method string, callback base.ReqCallba
}
return nil, errors.New(e.Error.Message)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *OnedriveAPP) getFiles(path string) ([]File, error) {

View File

@ -16,8 +16,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/OpenList/v4/server/common"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type OpenList struct {
@ -62,7 +62,7 @@ func (d *OpenList) Init(ctx context.Context) error {
if err != nil {
return err
}
allowMounted := utils.Json.Get(res.Body(), "data", conf.AllowMounted).ToString() == "true"
allowMounted := utils.Json.Get(res.Bytes(), "data", conf.AllowMounted).ToString() == "true"
if !allowMounted {
return fmt.Errorf("the site does not allow mounted")
}

View File

@ -8,8 +8,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/OpenList/v4/server/common"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
func (d *OpenList) login() error {
@ -50,7 +50,7 @@ func (d *OpenList) request(api, method string, callback base.ReqCallback, retry
if res.StatusCode() >= 400 {
return nil, res.StatusCode(), fmt.Errorf("request failed, status: %s", res.Status())
}
code := utils.Json.Get(res.Body(), "code").ToInt()
code := utils.Json.Get(res.Bytes(), "code").ToInt()
if code != 200 {
if (code == 401 || code == 403) && !utils.IsBool(retry...) {
err = d.login()
@ -59,7 +59,7 @@ func (d *OpenList) request(api, method string, callback base.ReqCallback, retry
}
return d.request(api, method, callback, true)
}
return nil, code, fmt.Errorf("request failed,code: %d, message: %s", code, utils.Json.Get(res.Body(), "message").ToString())
return nil, code, fmt.Errorf("request failed,code: %d, message: %s", code, utils.Json.Get(res.Bytes(), "message").ToString())
}
return res.Body(), 200, nil
return res.Bytes(), 200, nil
}

View File

@ -14,8 +14,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
hash_extend "github.com/OpenListTeam/OpenList/v4/pkg/utils/hash"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type PikPak struct {

View File

@ -22,9 +22,9 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/go-resty/resty/v2"
jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors"
"resty.dev/v3"
)
var AndroidAlgorithms = []string{
@ -121,7 +121,7 @@ func (d *PikPak) login() error {
if e.ErrorCode != 0 {
return &e
}
data := res.Body()
data := res.Bytes()
d.RefreshToken = jsoniter.Get(data, "refresh_token").ToString()
d.AccessToken = jsoniter.Get(data, "access_token").ToString()
d.Common.SetUserID(jsoniter.Get(data, "sub").ToString())
@ -157,7 +157,7 @@ func (d *PikPak) refreshToken(refreshToken string) error {
op.MustSaveDriverStorage(d)
return errors.New(e.Error())
}
data := res.Body()
data := res.Bytes()
d.Status = "work"
d.RefreshToken = jsoniter.Get(data, "refresh_token").ToString()
d.AccessToken = jsoniter.Get(data, "access_token").ToString()
@ -194,7 +194,7 @@ func (d *PikPak) request(url string, method string, callback base.ReqCallback, r
switch e.ErrorCode {
case 0:
return res.Body(), nil
return res.Bytes(), nil
case 4122, 4121, 16:
// access_token 过期
if err1 := d.refreshToken(d.RefreshToken); err1 != nil {

View File

@ -10,7 +10,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type PikPakShare struct {

View File

@ -14,7 +14,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
var AndroidAlgorithms = []string{
@ -100,7 +100,7 @@ func (d *PikPakShare) request(url string, method string, callback base.ReqCallba
}
switch e.ErrorCode {
case 0:
return res.Body(), nil
return res.Bytes(), nil
case 9: // 验证码token过期
if err = d.RefreshCaptchaToken(GetAction(method, url), ""); err != nil {
return nil, err

View File

@ -6,16 +6,17 @@ import (
"encoding/hex"
"errors"
"fmt"
"hash"
"io"
"net/http"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/errs"
"github.com/OpenListTeam/OpenList/v4/internal/model"
streamPkg "github.com/OpenListTeam/OpenList/v4/internal/stream"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"hash"
"io"
"net/http"
"resty.dev/v3"
)
type QuarkOpen struct {

View File

@ -8,19 +8,20 @@ import (
"encoding/hex"
"errors"
"fmt"
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/google/uuid"
"io"
"net/http"
"strconv"
"strings"
"time"
"github.com/OpenListTeam/OpenList/v4/pkg/http_range"
"github.com/google/uuid"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
func (d *QuarkOpen) request(ctx context.Context, pathname string, method string, callback base.ReqCallback, resp interface{}, manualSign ...*ManualSign) ([]byte, error) {
@ -79,7 +80,7 @@ func (d *QuarkOpen) request(ctx context.Context, pathname string, method string,
return nil, errors.New(e.ErrorInfo)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *QuarkOpen) GetFiles(ctx context.Context, parent string) ([]File, error) {

View File

@ -15,8 +15,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
streamPkg "github.com/OpenListTeam/OpenList/v4/internal/stream"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
type QuarkOrUC struct {

View File

@ -17,8 +17,8 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/cookie"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"resty.dev/v3"
)
// do others that not defined in Driver interface
@ -62,7 +62,7 @@ func (d *QuarkOrUC) request(pathname string, method string, callback base.ReqCal
if e.Status >= 400 || e.Code != 0 {
return nil, errors.New(e.Message)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *QuarkOrUC) GetFiles(parent string) ([]model.Obj, error) {

View File

@ -8,7 +8,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/errs"

View File

@ -13,7 +13,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/OpenListTeam/OpenList/v4/internal/op"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
const (
@ -82,7 +82,7 @@ func (d *QuarkUCTV) request(ctx context.Context, pathname string, method string,
if e.Status >= 400 || e.Errno != 0 {
return nil, errors.New(e.ErrorInfo)
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *QuarkUCTV) getLoginCode(ctx context.Context) (string, error) {

View File

@ -97,9 +97,9 @@ func (d *S3) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*mo
input.ResponseContentDisposition = &disposition
}
req, reqErr := d.linkClient.GetObjectRequest(input)
if reqErr != nil {
return nil, fmt.Errorf("failed to create GetObject request: %w", reqErr)
req, _ := d.linkClient.GetObjectRequest(input)
if req == nil {
return nil, fmt.Errorf("failed to create GetObject request")
}
var link model.Link
var err error

View File

@ -10,7 +10,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/internal/driver"
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
type Seafile struct {

View File

@ -11,7 +11,7 @@ import (
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
"github.com/OpenListTeam/OpenList/v4/drivers/base"
"github.com/go-resty/resty/v2"
"resty.dev/v3"
)
func (d *Seafile) getToken() error {
@ -68,7 +68,7 @@ func (d *Seafile) request(method string, pathname string, callback base.ReqCallb
if res.StatusCode() >= 400 {
return nil, fmt.Errorf("request failed: %s", res.String())
}
return res.Body(), nil
return res.Bytes(), nil
}
func (d *Seafile) getRepoAndPath(fullPath string) (repo *LibraryInfo, path string, err error) {

Some files were not shown because too many files have changed in this diff Show More