Skip to content

fix(guangyapan): rate-limit API requests to avoid flooding on batch copy#9553

Open
okatu-loli wants to merge 1 commit into
mainfrom
fix/guangyapan-api-rate-limit
Open

fix(guangyapan): rate-limit API requests to avoid flooding on batch copy#9553
okatu-loli wants to merge 1 commit into
mainfrom
fix/guangyapan-api-rate-limit

Conversation

@okatu-loli

Copy link
Copy Markdown
Collaborator

问题

光鸭(GuangYaPan)驱动所有 API 请求都经过 postAPI,但没有任何限流。跨盘复制多个文件时,每个复制任务都会并发调用光鸭接口(Link/get_res_download_urlcopy_fileget_file_list 等),瞬间打满上游接口、被风控。其它国产网盘驱动(如 123aliyundrive_open)都自带限流,光鸭没有,所以表现为「复制多个文件到其他网盘时任务数/请求不受控」。

修改

postAPI 入口加一个 per-endpointrate.Limiter(每个接口路径 500ms 一次,burst 1),参照 123 驱动的 APIRateLimit 模式。这样并发的复制任务会被按节奏排队,而不是同时打满光鸭接口;不同接口(列目录 / 取链接 / 复制)各自独立限流,互不影响。

  • 新增 GuangYaPan.apiRateLimit sync.Map 与常量 apiRateInterval = 500ms
  • 新增 apiRateLimitWait(ctx, path),在 postAPI 发请求前调用

影响

  • 所有走 postAPI 的操作(List/Link/Copy/Move 等)都会被限流,行为与其它「正常」网盘一致。
  • 取舍:超大文件夹的分页列表会略微变慢(每页间隔 500ms),与 123 驱动相同。

测试

go build ./drivers/guangyapan/ 通过。

Every GuangYaPan API call funnels through postAPI with no throttling, so
copying many files cross-storage fired unthrottled Link/copy/list requests
and overwhelmed the upstream API. Other Chinese pan drivers (123,
aliyundrive_open) self-throttle; guangya did not.

Add a per-endpoint rate.Limiter (one request per 500ms, applied in postAPI),
mirroring the 123 driver's APIRateLimit pattern, so concurrent copy tasks are
paced instead of flooding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant