- 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>
18 lines
791 B
TypeScript
18 lines
791 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { withAuth } from "@/lib/api-auth";
|
|
import { apiError } from "@/lib/api-errors";
|
|
import { deleteModel, ModelError } from "@/lib/models";
|
|
|
|
/** Delete a model; `?files=1` also deletes its files from disk (queued for the worker). */
|
|
export const DELETE = withAuth<RouteContext<"/api/models/[id]">>(async (req, { params }) => {
|
|
const { id } = await params;
|
|
try {
|
|
const deleteFiles = new URL(req.url).searchParams.get("files") === "1";
|
|
const { queued } = await deleteModel(id, { deleteFiles });
|
|
return queued ? NextResponse.json({ queued }, { status: 202 }) : new NextResponse(null, { status: 204 });
|
|
} catch (err) {
|
|
if (err instanceof ModelError) return apiError(err.status, err.code, err.message);
|
|
throw err;
|
|
}
|
|
});
|