mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-23 16:42:19 +00:00
Pause and resume now go through one process-level control plane that survives panel/terminal close: TransferRuntime + soft latches/epochs/walk registry, soft-then-hard resume, dual-epoch-safe progress, and no-owner soft control.
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import type { TransferTask } from "./models";
|
|
|
|
export function getGlobalTransferBatchEligibility(tasks: readonly TransferTask[]) {
|
|
const topLevel = tasks.filter((task) => !task.parentTaskId);
|
|
return {
|
|
pausableCount: topLevel.filter((task) => (
|
|
["pending", "queued", "transferring"].includes(task.status)
|
|
&& task.resumable !== false
|
|
&& !(task.ownerId === "dedicated-resume" && task.reconnectRequired)
|
|
)).length,
|
|
resumableCount: topLevel.filter((task) => (
|
|
!task.conflict
|
|
&& task.resumable !== false
|
|
&& (
|
|
["pausing", "paused", "interrupted", "attention"].includes(task.status)
|
|
|| (task.status === "failed" && (task.checkpointBytes ?? 0) > 0)
|
|
)
|
|
)).length,
|
|
};
|
|
}
|
|
|
|
export function listGloballyPausableTransferIds(tasks: readonly TransferTask[]): string[] {
|
|
return tasks.filter((task) => (
|
|
!task.parentTaskId
|
|
&& !(task.ownerId === "dedicated-resume" && task.reconnectRequired)
|
|
&& ["pending", "queued", "transferring", "pausing"].includes(task.status)
|
|
&& task.resumable !== false
|
|
)).map((task) => task.id);
|
|
}
|
|
|
|
export function listGloballyResumableTransferIds(tasks: readonly TransferTask[]): string[] {
|
|
return tasks.filter((task) => (
|
|
!task.parentTaskId
|
|
&& !task.conflict
|
|
&& task.resumable !== false
|
|
&& (
|
|
["paused", "pausing", "interrupted", "attention"].includes(task.status)
|
|
|| (task.status === "failed" && (task.checkpointBytes ?? 0) > 0)
|
|
)
|
|
)).map((task) => task.id);
|
|
}
|