feat(download): 下载器可设「H&R 未知也可清理」(M2)

下载器策略加 hnrUnknownCleanable(缺省关,保持现状):保种天数到期、站点 H&R 要求未知
(M-Team、接管任务、站点没配 H&R)的任务视为可清理;H&R 明确未满足的不受影响。
空间不足事项里写明有多少任务因 H&R 未知没清理、可在哪里放行。

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-10-03 23:20:29 +08:00
1 parent 3d3a4cefc6
commit 07d5f42143
3 files changed
+30 -8

No files matched your search

+15 -4
View File
@@ -97,16 +97,20 @@ const POLICY_FIELDS = [
["targetPct", "cleanupTargetPercent"],
["seedDays", "seedRetentionDays"],
] as const;
function policyForm(r: DownloaderInstance): Record<string, string> {
function policyForm(r: DownloaderInstance): Record<string, string | boolean> {
const p = ((r.settings as { policy?: Record<string, unknown> }).policy ?? {}) as Record<string, unknown>;
return Object.fromEntries(POLICY_FIELDS.map(([f, k]) => [f, typeof p[k] === "number" ? String(p[k]) : ""]));
return {
...Object.fromEntries(POLICY_FIELDS.map(([f, k]) => [f, typeof p[k] === "number" ? String(p[k]) : ""])),
hnrUnknownCleanable: p.hnrUnknownCleanable === true,
};
}
function policyBody(v: FormValues): Record<string, number> {
const out: Record<string, number> = {};
function policyBody(v: FormValues): Record<string, number | boolean> {
const out: Record<string, number | boolean> = {};
for (const [f, k] of POLICY_FIELDS) {
const raw = String(v[f] ?? "").trim();
if (raw !== "" && Number.isFinite(Number(raw))) out[k] = Number(raw);
}
if (v.hnrUnknownCleanable === true) out.hnrUnknownCleanable = true;
return out;
}
@@ -202,6 +206,12 @@ function DownloadersTable() {
placeholder: "留空用全局",
hint: "入库后至少保留几天再允许清理;公网 BT 可填 0(站点 H&R 要求仍然遵守)",
},
{
name: "hnrUnknownCleanable",
label: "H&R 未知也可清理",
kind: "switch",
hint: "保种天数到期后,没给出 H&R 要求的任务(如 M-Team、接管的任务、站点没配 H&R)也允许清理;默认不清理",
},
{
name: "isDefault",
label: "设为默认下载器",
@@ -223,6 +233,7 @@ function DownloadersTable() {
resumePct: "",
targetPct: "",
seedDays: "",
hnrUnknownCleanable: false,
isDefault: false,
enabled: true,
},