fix(xunlei):turn page

pull/1089/head
foxxorcat 2022-05-12 13:27:49 +08:00
parent 0eef7a129c
commit 041b3587bf
1 changed files with 4 additions and 2 deletions

View File

@ -171,14 +171,15 @@ func (driver XunLeiCloud) Files(path string, account *model.Account) ([]model.Fi
return nil, err return nil, err
} }
time.Sleep(time.Millisecond * 400) time.Sleep(time.Millisecond * 300)
files := make([]model.File, 0) files := make([]model.File, 0)
var pageToken string
for { for {
var fileList FileList var fileList FileList
_, err = GetClient(account).Request("GET", FILE_API_URL, func(r *resty.Request) { _, err = GetClient(account).Request("GET", FILE_API_URL, func(r *resty.Request) {
r.SetQueryParams(map[string]string{ r.SetQueryParams(map[string]string{
"parent_id": parentFile.Id, "parent_id": parentFile.Id,
"page_token": fileList.NextPageToken, "page_token": pageToken,
"with_audit": "true", "with_audit": "true",
"filters": `{"phase": {"eq": "PHASE_TYPE_COMPLETE"}, "trashed":{"eq":false}}`, "filters": `{"phase": {"eq": "PHASE_TYPE_COMPLETE"}, "trashed":{"eq":false}}`,
}) })
@ -195,6 +196,7 @@ func (driver XunLeiCloud) Files(path string, account *model.Account) ([]model.Fi
if fileList.NextPageToken == "" { if fileList.NextPageToken == "" {
break break
} }
pageToken = fileList.NextPageToken
} }
if len(files) > 0 { if len(files) > 0 {
_ = base.SetCache(path, files, account) _ = base.SetCache(path, files, account)