Files
Kaname/src/components/verify-result.tsx
T
Pascal LinxweilerandClaude Opus 5.5 7864a492c9 Delete, verify/deep verify, repair and update checks
- 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>
2026-10-06 01:00:55 +02:00

53 lines
2.3 KiB
TypeScript

import { CircleAlertIcon, CircleCheckIcon } from "lucide-react";
import type { JobResult } from "@/lib/db/schema";
import { formatBytes } from "@/lib/format";
import { cn } from "@/lib/utils";
function PathList({ title, paths, tone }: { title: string; paths: string[]; tone: "bad" | "muted" }) {
if (paths.length === 0) return null;
return (
<details className="text-xs">
<summary className={cn("cursor-pointer select-none", tone === "bad" ? "text-destructive" : "text-muted-foreground")}>
{title} ({paths.length})
</summary>
<ul className="mt-1 ml-3 flex flex-col gap-0.5 font-mono break-all text-muted-foreground">
{paths.slice(0, 50).map((p) => (
<li key={p}>{p}</li>
))}
{paths.length > 50 && <li>… {paths.length - 50} more</li>}
</ul>
</details>
);
}
/** Outcome of a (deep) verify: problems per kind, plus extra files in the folder. */
export function VerifyResult({ result, deep }: { result: JobResult; deep: boolean }) {
const missing = result.missing ?? [];
const sizeMismatch = result.sizeMismatch ?? [];
const hashMismatch = result.hashMismatch ?? [];
const extra = result.extra ?? [];
const problems = missing.length + sizeMismatch.length + hashMismatch.length;
const extraBytes = extra.reduce((s, e) => s + e.size, 0);
return (
<div className="flex flex-col gap-1.5">
<p className={cn("flex items-center gap-1.5 text-xs", problems > 0 ? "text-destructive" : "text-emerald-700 dark:text-emerald-400")}>
{problems > 0 ? <CircleAlertIcon className="size-3.5" /> : <CircleCheckIcon className="size-3.5" />}
{problems > 0
? `${problems} of ${result.checked ?? 0} files need repair`
: `All ${result.checked ?? 0} files OK${deep ? ", hashes match the Hub" : ""}`}
</p>
<PathList title="Missing" paths={missing} tone="bad" />
<PathList title="Wrong size" paths={sizeMismatch} tone="bad" />
<PathList title={deep ? "Hash mismatch" : "Different version (hf metadata)"} paths={hashMismatch} tone="bad" />
{extra.length > 0 && (
<PathList
title={`Extra files in the folder, ${formatBytes(extraBytes)}`}
paths={extra.map((e) => (e.inRepo ? `${e.path} (repo file, not selected)` : e.path))}
tone="muted"
/>
)}
</div>
);
}