hf has no bandwidth option, so the worker pauses hf (SIGSTOP/SIGCONT) whenever it is ahead of a token bucket over bytes on disk. The limit is shared by all running downloads and re-read every 5 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 lines
503 B
TypeScript
11 lines
503 B
TypeScript
// Download speed limit (Settings → Downloads). Shared by the settings API and the worker.
|
|
|
|
export const SPEED_LIMIT_KEY = "downloads.maxBytesPerSecond";
|
|
/** Smallest limit accepted (0.1 MB/s); below that hf's own timeouts start to bite. */
|
|
export const MIN_SPEED_LIMIT = 100_000;
|
|
|
|
/** The stored value as bytes per second, or null for no limit. */
|
|
export function parseSpeedLimit(v: unknown): number | null {
|
|
return typeof v === "number" && Number.isFinite(v) && v >= MIN_SPEED_LIMIT ? v : null;
|
|
}
|