- Delete any model (incl. failed ones); the worker removes the repo's files (keeps foreign files and empty-folder cleanup), then the rows. - Verify (existence, size, hf metadata) and deep verify (SHA-256 / git blob SHA-1 against the Hub) with missing/mismatch/extra report. - Repair = download of the selection; broken files are deleted first because hf skips files whose metadata matches without checking them. - Hub check resolves the tracked revision and stores which selected files a newer commit changes/adds/removes; Update pins it (old commit kept in model_revisions), downloads, then removes dropped files. - Worker runs verify/delete jobs next to downloads (2 local slots). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
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…");
|
|
}
|
|
|
|
export async function startVerify(modelId: string, deep: boolean) {
|
|
if (await post(`/api/models/${modelId}/verify${deep ? "?deep=1" : ""}`)) toast.success(deep ? "Deep verify queued" : "Verify queued");
|
|
}
|
|
|
|
export async function startRepair(modelId: string) {
|
|
if (await post(`/api/models/${modelId}/repair`)) toast.success("Repair queued");
|
|
}
|
|
|
|
export async function startUpdate(modelId: string): Promise<boolean> {
|
|
const ok = await post(`/api/models/${modelId}/update`);
|
|
if (ok) toast.success("Update queued");
|
|
return ok;
|
|
}
|