mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-21 23:50:45 +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.
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
/**
|
|
* Process-wide cancel flags for SFTP transfers.
|
|
*
|
|
* Directory walks and stream arms check these so Cancel from the global
|
|
* transfer center still stops work after the React owner unmounts.
|
|
*/
|
|
|
|
const cancelledIds = new Set<string>();
|
|
|
|
export function markTransferCancelled(taskId: string): void {
|
|
cancelledIds.add(taskId);
|
|
}
|
|
|
|
export function markTransferCancelledTree(rootTaskId: string, childIds: readonly string[] = []): void {
|
|
cancelledIds.add(rootTaskId);
|
|
for (const id of childIds) cancelledIds.add(id);
|
|
}
|
|
|
|
export function clearTransferCancelled(taskId: string): void {
|
|
cancelledIds.delete(taskId);
|
|
}
|
|
|
|
export function clearTransferCancelledTree(rootTaskId: string, childIds: readonly string[] = []): void {
|
|
cancelledIds.delete(rootTaskId);
|
|
for (const id of childIds) cancelledIds.delete(id);
|
|
}
|
|
|
|
export function isTransferCancelledFlag(taskId: string): boolean {
|
|
return cancelledIds.has(taskId);
|
|
}
|
|
|
|
export function isTransferOrRootCancelled(rootTaskId: string, taskId?: string): boolean {
|
|
return cancelledIds.has(rootTaskId) || (!!taskId && cancelledIds.has(taskId));
|
|
}
|
|
|
|
/** Test helper. */
|
|
export function resetTransferCancelLatchesForTests(): void {
|
|
cancelledIds.clear();
|
|
}
|