From f93d2fca0ce6d0840d4ec6f6b420fe9aa7de79b3 Mon Sep 17 00:00:00 2001 From: wzdc Date: Tue, 14 Jul 2026 22:29:13 +0800 Subject: [PATCH 1/2] fix(drivers/189pc,drivers/189tv): fix extra requests when viewing files --- drivers/189_tv/utils.go | 13 +++++++++++-- drivers/189pc/utils.go | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/189_tv/utils.go b/drivers/189_tv/utils.go index cea9411ecf..f44338e382 100644 --- a/drivers/189_tv/utils.go +++ b/drivers/189_tv/utils.go @@ -218,13 +218,22 @@ func (y *Cloud189TV) getFiles(ctx context.Context, fileId string, isFamily bool) if resp.FileListAO.Count == 0 { break } + + FolderCount := len(resp.FileListAO.FolderList) // 当前文件夹总数 + FileCount := len(resp.FileListAO.FileList) // 当前文件总数 + PageCount := FolderCount + FileCount // 当前页数总数 - for i := 0; i < len(resp.FileListAO.FolderList); i++ { + for i := 0; i < FolderCount; i++ { res = append(res, &resp.FileListAO.FolderList[i]) } - for i := 0; i < len(resp.FileListAO.FileList); i++ { + for i := 0; i < FileCount; i++ { res = append(res, &resp.FileListAO.FileList[i]) } + + // 文件数量小于130则跳出 + if PageCount < 130 { + break + } } return res, nil } diff --git a/drivers/189pc/utils.go b/drivers/189pc/utils.go index f46c5c0059..17112d766f 100644 --- a/drivers/189pc/utils.go +++ b/drivers/189pc/utils.go @@ -205,14 +205,23 @@ func (y *Cloud189PC) getFiles(ctx context.Context, fileId string, isFamily bool) if resp.FileListAO.Count == 0 { break } + + FolderCount := len(resp.FileListAO.FolderList) // 当前文件夹总数 + FileCount := len(resp.FileListAO.FileList) // 当前文件总数 + PageCount := FolderCount + FileCount // 当前页数总数 - for i := 0; i < len(resp.FileListAO.FolderList); i++ { + for i := 0; i < FolderCount; i++ { res = append(res, &resp.FileListAO.FolderList[i]) } - for i := 0; i < len(resp.FileListAO.FileList); i++ { + for i := 0; i < FileCount; i++ { resp.FileListAO.FileList[i].ParentID = fileId res = append(res, &resp.FileListAO.FileList[i]) } + + // 当前文件数量小于1000则跳出 + if PageCount < 1000 { + break + } } return res, nil } From 30e9515b4a57273c1efebfe6410bb5562556adf4 Mon Sep 17 00:00:00 2001 From: wzdc Date: Wed, 15 Jul 2026 19:35:04 +0800 Subject: [PATCH 2/2] fix(drivers/189pc,drivers/189tv): fix extra requests when viewing files --- drivers/189_tv/utils.go | 7 ++++--- drivers/189pc/utils.go | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/189_tv/utils.go b/drivers/189_tv/utils.go index f44338e382..313f1dc5e4 100644 --- a/drivers/189_tv/utils.go +++ b/drivers/189_tv/utils.go @@ -184,6 +184,7 @@ func (y *Cloud189TV) getFiles(ctx context.Context, fileId string, isFamily bool) } fullUrl += "/listFiles.action" + pageSize := 130 // 每一页返回的文件数量 res := make([]model.Obj, 0, 130) for pageNum := 1; ; pageNum++ { var resp Cloud189FilesResp @@ -195,7 +196,7 @@ func (y *Cloud189TV) getFiles(ctx context.Context, fileId string, isFamily bool) "mediaAttr": "0", "iconOption": "5", "pageNum": fmt.Sprint(pageNum), - "pageSize": "130", + "pageSize": fmt.Sprint(pageSize), }) if isFamily { r.SetQueryParams(map[string]string{ @@ -230,8 +231,8 @@ func (y *Cloud189TV) getFiles(ctx context.Context, fileId string, isFamily bool) res = append(res, &resp.FileListAO.FileList[i]) } - // 文件数量小于130则跳出 - if PageCount < 130 { + // 文件数量小于设定数量时跳出 + if PageCount < pageSize { break } } diff --git a/drivers/189pc/utils.go b/drivers/189pc/utils.go index 17112d766f..3e87a1995b 100644 --- a/drivers/189pc/utils.go +++ b/drivers/189pc/utils.go @@ -195,9 +195,10 @@ func (y *Cloud189PC) put(ctx context.Context, url string, headers map[string]str } func (y *Cloud189PC) getFiles(ctx context.Context, fileId string, isFamily bool) ([]model.Obj, error) { + pageSize := 1000 // 每一页返回的文件数量 res := make([]model.Obj, 0, 100) for pageNum := 1; ; pageNum++ { - resp, err := y.getFilesWithPage(ctx, fileId, isFamily, pageNum, 1000, y.OrderBy, y.OrderDirection) + resp, err := y.getFilesWithPage(ctx, fileId, isFamily, pageNum, pageSize, y.OrderBy, y.OrderDirection) if err != nil { return nil, err } @@ -218,8 +219,8 @@ func (y *Cloud189PC) getFiles(ctx context.Context, fileId string, isFamily bool) res = append(res, &resp.FileListAO.FileList[i]) } - // 当前文件数量小于1000则跳出 - if PageCount < 1000 { + // 当前文件数量小于设定数量则跳出 + if PageCount < pageSize { break } }