Downloads: speed limit in Settings

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>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-13 10:04:48 +02:00
1 parent b623b16a6d
commit 85af566b93
9 files changed
+285 -8

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
// 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;
}