- Worker queue with per-model exclusivity and MAX_CONCURRENT_DOWNLOADS, spawns `hf download --revision <sha> --local-dir ... --include <exact paths>` with HF_TOKEN via env only - Progress from bytes on disk (final + .incomplete files matched by etag), per job and per file, with speed and ETA; post-download size/etag check - Job logs (sanitized), cancel, graceful interrupt on shutdown, partial-file cleanup (hf 2.1.1 does not resume partials) - Single-worker DB lease, free-space check - SSE live updates for library, model and job pages - Dockerfile + compose.yaml (web, worker, data/models volumes) - HF_HUB_DISABLE_XET default on for measurable progress Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
594 B
TypeScript
20 lines
594 B
TypeScript
"use client";
|
|
|
|
import { toast } from "sonner";
|
|
|
|
async function post(url: string): Promise<boolean> {
|
|
const res = await fetch(url, { method: "POST" });
|
|
if (res.ok) return true;
|
|
const body = await res.json().catch(() => ({}));
|
|
toast.error(body.error?.message ?? `Request failed (${res.status})`);
|
|
return false;
|
|
}
|
|
|
|
export async function startDownload(modelId: string) {
|
|
if (await post(`/api/models/${modelId}/download`)) toast.success("Download queued");
|
|
}
|
|
|
|
export async function cancelJob(jobId: string) {
|
|
if (await post(`/api/jobs/${jobId}/cancel`)) toast.info("Cancelling…");
|
|
}
|