Repository navigation
Conversation
added 2 commits
November 9, 2026 18:57
Replace the placeholder /api/task/* implementation with a real queue: - TaskRunner Durable Object (SQLite + alarm) executes tasks and keeps them across invocations; auto-recovers zombie tasks and chains alarms until the queue is idle. Falls back to a per-type JSON document store when no DO binding exists (EdgeOne / ESA / Vercel / Node), driven by cron or POST /api/task/run. - copy/move become background tasks above a configurable size threshold (task_sync_threshold_mb, default 32MB); small operations stay synchronous and are still recorded in the done list. - Cross-storage copies previously handed the destination physical path to the source driver, which silently misbehaved. A shared transfer engine now supports rapidUpload -> putUrl -> resumable multipart -> putStream -> bounded buffer, with the multipart cursor persisted for resumability. - URL offline download replaces the old 501. It is disabled unless ALLOW_OFFLINE_DOWNLOAD lists the target hosts; SSRF checks still apply. - Tick budget defaults to a free-plan-safe 2s and is configurable per deployment (200-60000ms); parallel unit count is capped at 4. - Tasks are verified before being marked succeeded (target existence, file counts, source removal for moves) and expose the same TaskInfo/state numbers as the Go backend. - Add settings, docs, wrangler bindings (TASK_DO + v2 migration + cron) and tests for the store, runner, settings, API contract and download allowlist.
Open
3 of 4 tasks
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
openlist-work | 4b81819 | Nov 10 2026, 10:04 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
openlist-tsworkers | 4b81819 | Nov 10 2026, 10:04 AM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / 摘要
把
/api/task/*从占位实现换成真正的持久化任务队列,并把长耗时文件操作从请求内移到后台执行。用户可感知的变化
task_sync_threshold_mb,默认 32MB)时改为后台任务,接口立即返回data.tasks;小操作仍在请求内完成,并同样出现在「已完成」任务列表。POST /api/fs/add_offline_download)从固定的 501 变成可用功能;默认关闭,需显式配置主机白名单。实现要点
TaskRunnerDurable Object:任务存内置 SQLite(按行更新)、alarm自驱执行、入队即开跑;僵尸任务自动回收,连续无进展熔断。POST /api/task/run驱动。internal/op/transfer.ts:rapidUpload → putUrl(服务端直传)→ 可续传分片 → putStream → 限内存缓冲;分片会话写入 cursor,大文件中途被打断可续传。task_tick_budget_ms,0=自动,200–60000ms);默认 2000ms,按免费计划保守取值。succeeded前强制校验(目标存在性、文件数、move 源已删除),校验失败直接判失败并给出差集。wrangler.jsonc增加TASK_DO绑定、v2migration 与每分钟 cron。配置 / 兼容性变化
/fs/copy、/fs/move在大操作下改为异步并返回data.tasks(对齐 Go 的FsCopy/FsMove);小操作响应不变。/fs/add_offline_download不再是 501;未配置ALLOW_OFFLINE_DOWNLOAD时返回 403。新增环境变量:
ALLOW_OFFLINE_DOWNLOAD、PUBLIC_ORIGIN(后台解析相对下载直链用)。部署会新增一个
TaskRunnerDO 命名空间(免费计划支持 SQLite DO),migration tagv2。This PR has breaking changes.
/ 此 PR 包含破坏性变更。
This PR changes public API, config, storage format, or migration behavior.
/ 此 PR 修改了公开 API、配置、存储格式或迁移行为。
This PR requires corresponding changes in related repositories.
/ 此 PR 需要关联仓库同步修改。
Related repository PRs / 关联仓库 PR:
Related Issues / 关联 Issue
Relates to #___
Testing / 测试
npx tsc -p tsconfig.json --noEmit(类型检查通过)npx tsx --test "src/backend/internal/task/*.test.ts"(19 项通过)npx tsx --test src/backend/internal/task/handlers/offline_download.test.ts(7 项通过)npx tsx --test src/backend/server/task_api.test.ts(10 项通过)npx tsx --test "src/backend/server/*.test.ts"(244 项,243 通过)npm run test:model(39 项通过)npm run test:pkg(33 项通过)npx tsx scripts/test-task-api.mts(冒烟通过)npx wrangler deploy --dry-run(打包通过,识别TASK_DO绑定)说明:
server套件中storage_update_guangyapan.test.ts失败,但在未改动的干净代码上同样失败(已用
git stash在原始 HEAD 上复现),与本次改动无关。Checklist / 检查清单
/ 我已阅读 CONTRIBUTING。
/ 我确认此贡献符合仓库许可证、贡献规范和行为准则。
prettierwhere applicable./ 我已按适用情况使用
prettier格式化变更代码。说明:本机工作区为 CRLF,
prettier --check对仓库内既有文件同样报错(整文件行尾差异),为避免产生数千行无意义 diff 未执行
prettier --write;新文件已按仓库风格编写。/ 我已在适用情况下请求相关维护者或代码所有者审查。
AI Disclosure / AI 使用声明
/ 此 PR 包含 AI 辅助内容。
Tools used / 使用工具:
Usage scope / 使用范围:
Code generation / 代码生成
Refactoring / 重构
Documentation / 文档
Tests / 测试
Translation / 翻译
Review assistance / 审查辅助
I have reviewed and validated all AI-assisted content included in this PR.
/ 我已审核并验证此 PR 中的所有 AI 辅助内容。
I have ensured that all AI-assisted commits include
Co-Authored-Byattribution./ 我已确保所有 AI 辅助提交都包含
Co-Authored-By归属信息。I can reproduce all AI-assisted content included in this PR without any AI tools.
/ 我可以在没有任何 AI 工具的情况下重现此 PR 中包含的所有 AI 辅助内容。
Reviewer Notes / 审查要点
src/backend/internal/task/runner.ts:认领 / 断点 / 取消 / 退避 / 熔断 / 校验的唯一入口。src/backend/durable-objects/TaskRunner.ts:SQLite claim 用单条UPDATE ... RETURNING,避免并发重复执行。src/backend/internal/op/transfer.ts:安全相关(逐跳 SSRF 校验、allowHosts)与续传逻辑。src/backend/server/fs.ts:decideCopyMoveMode决定同步/异步;注意顶层条目一条任务(与 Go 一致)。