The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
docs(adr): 清理过时的 ADR,精简 0010
XiaoYouChRce36b5de762b
diff --git a/docs/adr/0003-unified-error-boundary-in-task-run.md b/docs/adr/0003-unified-error-boundary-in-task-run.mddeleted file mode 100644index 9f9afe9e..00000000--- a/docs/adr/0003-unified-error-boundary-in-task-run.md+++ /dev/null@@ -1,31 +0,0 @@-# Unified error boundary in Task.run()--All step error handling is unified through a single catch point in `Task.run()`.-Steps raise `TaskError` for known business errors or let unexpected exceptions-propagate. `Task.run()` catches both and stores a `TaskError` on the step.-No protocol overrides `Task.run()` — BT and ED2k moved their logic into-`BTTaskStep.run()` / `ED2kTaskStep.run()` so the boundary is universal.--Error messages are templates carrying format parameters, written in the source-language (`zh_CN`). The View translates at render time via-`QCoreApplication.translate("TaskErrors", msg)`, keeping Qt out of the logic-layer. Pack-specific `features/*/i18n.py` files provide `N()` markers for-`lupdate`; they are never imported.--Step errors are not serialized (`repr=False`). Failed tasks loaded from a-previous session show FAILED status without error detail — the user can retry-for a fresh error message.--## Considered Options--- **Step-level catch (status quo before this change)**: every step had- `except Exception as e: self.setError(e); raise` — 10+ identical blocks,- error messages were `repr(exception)`, no i18n, no structured parameters.--- **Task-level auto-retry on transient errors**: rejected because every- protocol that benefits from retry already has it at the subworker or session- level. Task-level failures are almost always permanent or require user- intervention. A `retryable` flag can be added non-breakingly later if needed.--- **Translate at raise time (`QCoreApplication.translate` in step)**: rejected- because it puts Qt in the logic layer. The View layer owns translation.diff --git a/docs/adr/0004-android-popup-must-be-child-widget.md b/docs/adr/0004-android-popup-must-be-child-widget.mddeleted file mode 100644index b0c936b6..00000000--- a/docs/adr/0004-android-popup-must-be-child-widget.md+++ /dev/null@@ -1,22 +0,0 @@-# Android popups must be child widgets, not top-level windows--PySide6 on Android with EGL: any second top-level window (`Qt.Popup`,-`Qt.Dialog` without a parent, or a detached `RoundMenu`) triggers the-`AndroidDeadlockProtector` in the surfaceflinger path. The EGL surface is-single-threaded; a second surface creation deadlocks against the first.-The result is a crash on devices with slow GL drivers — device-specific, not-reproducible in the emulator.--All popup-like widgets (RoundMenu, Flyout, TeachingTip) must be reparented-as child widgets of the main window. `patches.py` does this globally via-`patchMenus()`. A side-effect: `WA_DeleteOnClose` menus crash on focus-teardown during destruction (`SIGSEGV` via `libsigchain`). Fix:-`host.setFocus()` before the menu hides.--## Considered Options--- **Use QDialog with parent** — rejected: QDialog still creates a separate- window handle on Android. Only embedding as a plain child widget avoids the- second surface.-- **Disable hardware acceleration** — rejected: unacceptable rendering- performance.diff --git a/docs/adr/0005-android-native-binary-exec-via-linker64.md b/docs/adr/0005-android-native-binary-exec-via-linker64.mddeleted file mode 100644index 6136ddfd..00000000--- a/docs/adr/0005-android-native-binary-exec-via-linker64.md+++ /dev/null@@ -1,22 +0,0 @@-# Android native binary execution via linker64, ffmpeg stays pre-bundled--Android 10+ enforces W^X: files outside the APK's `nativeLibraryDir` cannot-be executed. Downloaded binaries (N_m3u8DL-RE) must be invoked through-`/system/bin/linker64 <path>` to bypass SELinux exec restrictions. This has-been validated on-device.--FFmpeg must stay pre-bundled in `nativeLibraryDir` (via the `gd3ffmpeg` p4a-recipe). N_m3u8DL-RE internally exec's ffmpeg as a child process and does not-use our linker64 wrapper — if ffmpeg is outside `nativeLibraryDir`,-N_m3u8DL-RE's internal exec fails silently.--Only N_m3u8DL-RE can be runtime hot-installed (~20 MB APK savings).-Implementation is deferred.--## Considered Options--- **Bundle all binaries in nativeLibraryDir** — rejected as the long-term- goal: N_m3u8DL-RE is ~20 MB and updates independently of the app. Bundling- it inflates the APK and requires a full app update for runtime upgrades.-- **Use app_process instead of linker64** — rejected: `app_process` requires- Java class loading, not suitable for plain native executables.diff --git a/docs/adr/0006-android-package-name.md b/docs/adr/0006-android-package-name.mddeleted file mode 100644index 58892642..00000000--- a/docs/adr/0006-android-package-name.md+++ /dev/null@@ -1,11 +0,0 @@-# Android package name: `io.github.xiaoyouchr.ghostdownloader`--The Android package name is `io.github.xiaoyouchr.ghostdownloader` with-display name "Ghost Downloader". The package name and display title are-decoupled via environment variables (`GD3_PKG_DOMAIN`, `GD3_PKG_NAME`,-`GD3_APP_TITLE`) in the build system — p4a's `--package` flag does not-tolerate spaces, but the display title needs them.--Once users install the app, the package name can never change — Android-identifies apps by package name, and a change would force a full uninstall-(losing user data and download history).diff --git a/docs/adr/0010-compose-command-errors-are-view-bugs.md b/docs/adr/0010-compose-command-errors-are-view-bugs.mdindex 8803c105..5ea9f45f 100644--- a/docs/adr/0010-compose-command-errors-are-view-bugs.md+++ b/docs/adr/0010-compose-command-errors-are-view-bugs.md@@ -1,49 +1,21 @@-# compose 的命令失败走 View 防御,不建第二条 i18n 链+# Compose 命令失败是 View 的 bug,不是用户条件-引擎运行时错误的 i18n 通路已经存在:`TaskError(message, params)` → `engineText()` → 生成的-`EngineStrings.kt` → 8 个 locale。Desktop 侧是 `toTaskError` catch-all + `toLocalizedError`-单一出口。+Engine 投影能力字段(`canEdit`、`canRename`、`canProbeMedia`),View 据此禁用操作。命令到达+engine.py 时它已经合法——如果不合法,是 View 漏了校验。不为 View 的 bug 建错误报告基础设施。-compose 的缺口在展示:`PyException.getMessage()` 是 `"{TypeName}: {str(e)}"`,已包装的 catch-点直接显示 `e.message`,而 ViewModel 又没有 `Context`,翻译不了——所以它们把错误存成-`String?`,在渲染时已经是一句死的英文。+错误展示复用已有 i18n 链:`Throwable.toTaskError()` 剥 PyException 前缀,`engineText(TaskError)`+查 `engineStrings` 翻译模板,未命中则兜底 `发生了意外错误:{detail}`。ViewModel 存 `TaskError?`+(机器可读 key),View 在渲染时翻译。`query` 失败 raise,View 显示翻译消息;`invoke` 的竞态守卫+静默 return(与 `pause`/`remove`/`stopTask` 查不到 id 就 return 同构)。-决定:+## Consequences-- **展示侧归一化,桥不加接口。** 加 `Throwable.toTaskError()` 与 `engineText(TaskError)` /- `engineText(Throwable)` 重载:剥掉 `"{TypeName}: "` 前缀,**命中 `engineStrings` 就当作模板**,- 否则包进已注册的兜底模板 `发生了意外错误:{detail}`——与 Desktop 的 `toTaskError` 同一契约。- 盲剥会把 `"HTTP 403: Forbidden"` 剥成 `"Forbidden"`,所以先用 `containsKey` 判别。-- **ViewModel 的错误状态一律是 `TaskError?`,不是 `String?`。** 这是根 `CONTEXT.md:105`- 的既有约定(model 存机器可读 key,View 映射到翻译文本),`TaskUiState.error` 早就是这个形状。- 统一到它,而不是新造。渲染统一走 `ui/components/ErrorText.kt`。-- **不加 `EngineError` 类型。** 删除测试:删掉它调用方 `catch (e: Exception)` 一字不用改,- 它不提供任何东西。需要区分「引擎说不行」和「桥断了/解码失败」时再加。-- **不加 `post()`。** 需要它是基于「约 10 处裸 `launch` 会崩进程」的判断,而那个判断没验。-- **`engine.py` 的校验按桥的两个方法分开**:`query` 语义(View 要拿数据)的失败必须- `raise`,View 显示翻译后的消息;`invoke` 语义(发了就行)的竞态守卫**静默返回**,与引擎- 自己的既有模式同构(`pause` / `remove` / `stopTask` 查不到 id 就 `return`)。View 仍然要- 禁用注定失败的操作(「View 是校验边界」),引擎的静默只兜住 render 与 tap 之间那 100ms 的- 窗口——两者都要,不是二选一。-- **`engine.py` 的值/能力校验一律删除**(`raise ValueError` 归零)。View 是校验边界——它用引擎- 投影出的能力字段(`canEdit`、`canRename`、`canProbeMedia`)提前禁用操作,Service 信任它送来的- 值,不重复校验。只保留「按 id 查不到就 `return`」这一种守卫,因为那是引擎自己的既有模式- (`pause` / `remove` / `stopTask` 都这样),是查找失败的一致处理而非防御。+- engine.py 的 `raise ValueError` 归零——View 是校验边界,Engine 不重复校验。+- 只保留「按 id 查不到就 return」这一种守卫,是查找失败的一致处理。## Considered Options-- **把裸 `launch` 逐条加防护**:曾写进本 ADR,撤销。引擎的命令层是防御式写的——`pause`- `resume` `stopTask` `remove` `redownload` `installRuntime` `setBrowserPairApproval` 查不到- id 就 `return`,**不抛**。给它们加 catch 是 hypothetical 防御。逐条查完,真正可能抛的只有- `setSetting`(`cfg.byName[name]` 的 `KeyError`)和 `requestPack`(pack 业务错误),而前者- 只在传了不存在的设置名时发生——那是编程错误,不是用户条件。-- **`EngineRepository` 补 catch-all,抛携带模板的类型化异常**:曾写进本 ADR,撤销。catch 后- 再抛不解决崩溃;而带参数的模板在 `TaskError.__str__` 里就被 `format_map` 替换掉了,过桥后- 已不是模板,剥前缀对它们无效。-- **建 Android 侧独立 i18n 链,逐条翻译那 14 条**:把 bug 当需求做。这些错误本不该出现——- `canEdit` 已经在数据里,View 本该禁用按钮;「查不到」是竞态,正确反应是刷新而不是弹文案。-- **把 `compose/app/src/main/python` 加进 `sync_i18n_res.py` 的扫描 roots**:方向反了。- 共享链服务 Desktop + engine + packs,让 App 的知识进共享层会污染 Desktop 的 `.ts` 资产。- 对称于「Packs 知识不进 App」:App 知识也不进共享层。-- **`invoke` 吞掉异常并推 Notice**:会剥夺已包装点的能力——`TaskViewModel` 的失败计数、- `TasksPage` 的 snackbar 会变成死代码。+- **建 Android 侧独立 i18n 链**:把 bug 当需求做。这些错误本不该出现。+- **EngineRepository 补 catch-all 再抛类型化异常**:catch 后再抛不解决崩溃;模板过桥后已被+ `format_map` 替换,不再是模板。+- **`invoke` 吞异常并推 Notice**:剥夺已包装点的能力(TaskViewModel 失败计数、snackbar)。