fix(download): 连续 3 轮查不到才判移除(M1)
qB 列表与按 hash 都查不到时先记 missing_since / missing_count,连续 MISSING_CONFIRM_ROUNDS(3) 轮才判 removed;中途重新出现或只是去掉管理标签即清零。相关测试改为同步多轮后再断言移除。 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
1 parent
cba5de731b
commit
d96f0ff19f
4 files changed
+25
-6
No files matched your search
@@ -2,7 +2,11 @@ import { createQbClient } from "@umt/adapters";
|
||||
import { createMockQb, createTempTree, type MockQb, makeTorrent, type TempTree } from "@umt/testkit";
|
||||
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
||||
import { evaluateAcquisition } from "../../src/modules/acquisition-organize/services/acquisition.ts";
|
||||
import { submitDownload, syncDownloads } from "../../src/modules/acquisition-organize/services/downloads.ts";
|
||||
import {
|
||||
MISSING_CONFIRM_ROUNDS,
|
||||
submitDownload,
|
||||
syncDownloads,
|
||||
} from "../../src/modules/acquisition-organize/services/downloads.ts";
|
||||
import { executeRecord, planImport } from "../../src/modules/acquisition-organize/services/organize.ts";
|
||||
import {
|
||||
applyEpisodeTotal,
|
||||
@@ -159,7 +163,7 @@ describe.skipIf(!hasPg)("订阅增强(真实 PG + mock qB + 临时目录)", () =
|
||||
// 用户在 qB 里删掉 E02:确认移除 → 计划失败释放单元 → Slot 到期重评 → 延后的 E02 另一版本得到计划
|
||||
const qc = createQbClient({ instanceId: "t", baseUrl: qb.url, username: "admin", password: "adminadmin" });
|
||||
await qc.delete([e2.hash], { deleteFiles: false });
|
||||
await syncDownloads(h.d);
|
||||
for (let i = 0; i < MISSING_CONFIRM_ROUNDS; i++) await syncDownloads(h.d);
|
||||
expect(await planRow(p2)).toMatchObject({ status: "failed", status_reason: "download_removed" });
|
||||
expect((await slotRow(slotId)).status).toBe("attention");
|
||||
h.engine.enqueued.length = 0;
|
||||
|
||||
@@ -41,6 +41,8 @@ describe.skipIf(!hasPg)("E15 Agent 质量(fake 模型 + 真实能力)", () => {
|
||||
name: "Dune.Part.Two.2024.1080p.BluRay.x264-GRP",
|
||||
status: "failed",
|
||||
last_error: JSON.stringify({ message: "qB 状态 missingFiles" }),
|
||||
// 已连续缺席两轮:下一轮同步即确认移除(多轮缺席才判移除)
|
||||
missing_count: 2,
|
||||
})
|
||||
.returning("id")
|
||||
.executeTakeFirstOrThrow()
|
||||
|
||||
@@ -2,7 +2,7 @@ import { createQbClient } from "@umt/adapters";
|
||||
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
||||
import type { createAcquisitionOrganizeModule } from "../../src/modules/acquisition-organize/index.ts";
|
||||
import { evaluateAcquisition } from "../../src/modules/acquisition-organize/services/acquisition.ts";
|
||||
import { syncDownloads } from "../../src/modules/acquisition-organize/services/downloads.ts";
|
||||
import { MISSING_CONFIRM_ROUNDS, syncDownloads } from "../../src/modules/acquisition-organize/services/downloads.ts";
|
||||
import { torrentFor } from "./fixtures/modules.ts";
|
||||
import { createE2E, type E2E, pgAvailable, seedBase, waitFor } from "./harness.ts";
|
||||
|
||||
@@ -206,7 +206,8 @@ describe.skipIf(!hasPg)("E8 AT24 标签移除 / 任务消失", () => {
|
||||
});
|
||||
await ext.delete([ids.D.hash], { deleteFiles: false });
|
||||
const externalDeletes = e.qb.callsTo("torrents/delete").length;
|
||||
await syncDownloads(deps());
|
||||
// 连续多轮查不到才确认移除
|
||||
for (let i = 0; i < MISSING_CONFIRM_ROUNDS; i++) await syncDownloads(deps());
|
||||
const row = await dt("D");
|
||||
expect(row.status).toBe("removed");
|
||||
expect(row.removed_at).not.toBeNull();
|
||||
|
||||
Reference in new issue
Block a user