整理:被排除的待确认视频不算成功
季集待确认 / 没有季目录 / 命名失败而被排除的视频(excluded:episode_unresolved / no_target_dir / naming_failed)让整理记录从 succeeded 降为 partial;样例、过小、已在库等预期跳过不受影响。 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
1 parent
00045a24cb
commit
70935f4c17
2 files changed
+39
-7
No files matched your search
@@ -142,16 +142,38 @@ export function organizePlanToFileResults(
|
||||
return [...planned, ...excluded];
|
||||
}
|
||||
|
||||
/** 逐文件状态 → 整理记录状态(全部完成后调用;仍有 queued/running 时为 running) */
|
||||
export function organizationStatusFromFiles(statuses: readonly FileResultStatus[]): OrganizationStatus {
|
||||
/**
|
||||
* 被排除但"本该入库"的视频:季集没定下来、没有对应季目录、命名缺字段。文件留在原处没人管,
|
||||
* 不能算整理成功(Move 成功后会移除下载任务)。样例、过小、已在库等预期跳过不在此列。
|
||||
*/
|
||||
export const UNRESOLVED_EXCLUSIONS = ["episode_unresolved", "no_target_dir", "naming_failed"] as const;
|
||||
const UNRESOLVED_SKIP = new Set<string>(UNRESOLVED_EXCLUSIONS.map((r) => `excluded:${r}`));
|
||||
|
||||
/** 文件结果的 skip_reason 是否属于"本该入库却被排除" */
|
||||
export const isUnresolvedExclusion = (skipReason: string | null | undefined): boolean =>
|
||||
!!skipReason && UNRESOLVED_SKIP.has(skipReason);
|
||||
|
||||
/**
|
||||
* 逐文件状态 → 整理记录状态(全部完成后调用;仍有 queued/running 时为 running)。
|
||||
* unresolved:被排除的待确认视频数(isUnresolvedExclusion),有则成功降为 partial。
|
||||
*/
|
||||
export function organizationStatusFromFiles(
|
||||
statuses: readonly FileResultStatus[],
|
||||
opts: { unresolved?: number } = {},
|
||||
): OrganizationStatus {
|
||||
if (statuses.some((s) => s === "queued" || s === "running")) return "running";
|
||||
const done = statuses.filter((s) => s !== "skipped");
|
||||
// 全部跳过(或没有文件)视为成功:没有需要做的事
|
||||
if (done.length === 0) return "succeeded";
|
||||
const ok = done.filter((s) => s === "succeeded").length;
|
||||
if (ok === done.length) return "succeeded";
|
||||
if (done.every((s) => s === "cancelled")) return "cancelled";
|
||||
return ok > 0 ? "partial" : "failed";
|
||||
// 全部跳过(或没有文件)视为成功:没有需要做的事
|
||||
const base: OrganizationStatus =
|
||||
done.length === 0 || ok === done.length
|
||||
? "succeeded"
|
||||
: done.every((s) => s === "cancelled")
|
||||
? "cancelled"
|
||||
: ok > 0
|
||||
? "partial"
|
||||
: "failed";
|
||||
return base === "succeeded" && (opts.unresolved ?? 0) > 0 ? "partial" : base;
|
||||
}
|
||||
|
||||
/** 整理计划 → organize.plan 能力输出(planId / payloadHash 由保存计划的一方给出) */
|
||||
|
||||
@@ -177,6 +177,16 @@ describe("整理计划 → 整理记录", () => {
|
||||
expect(M.organizationStatusFromFiles(["succeeded", "running"])).toBe("running");
|
||||
expect(M.organizationStatusFromFiles(["cancelled"])).toBe("cancelled");
|
||||
expect(M.organizationStatusFromFiles([])).toBe("succeeded");
|
||||
// 被排除的待确认视频(季集 / 季目录 / 命名)让成功降为 partial;预期跳过不影响
|
||||
expect(M.organizationStatusFromFiles(["succeeded", "skipped"], { unresolved: 1 })).toBe("partial");
|
||||
expect(M.organizationStatusFromFiles(["succeeded", "failed"], { unresolved: 1 })).toBe("partial");
|
||||
expect(M.organizationStatusFromFiles(["failed", "skipped"], { unresolved: 1 })).toBe("failed");
|
||||
expect(M.isUnresolvedExclusion("excluded:episode_unresolved")).toBe(true);
|
||||
expect(M.isUnresolvedExclusion("excluded:no_target_dir")).toBe(true);
|
||||
expect(M.isUnresolvedExclusion("excluded:naming_failed")).toBe(true);
|
||||
expect(M.isUnresolvedExclusion("excluded:too_small")).toBe(false);
|
||||
expect(M.isUnresolvedExclusion("already_in_library")).toBe(false);
|
||||
expect(M.isUnresolvedExclusion(null)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user