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>
This commit is contained in:
1 parent
c2c239bf16
commit
7864a492c9
37 files changed
+2365
-191
No files matched your search
+28
-1
@@ -50,6 +50,30 @@ export type ModelStatus = (typeof MODEL_STATUSES)[number];
|
||||
export const HUB_STATES = ["available", "repo_missing", "commit_missing"] as const;
|
||||
export type HubState = (typeof HUB_STATES)[number];
|
||||
|
||||
export type UpdateDiffFile = { path: string; size: number; oldSize?: number };
|
||||
export type UpdateDiff = {
|
||||
/** Commit the diff was computed against (the tracked revision's head on the Hub). */
|
||||
sha: string;
|
||||
changed: UpdateDiffFile[];
|
||||
added: UpdateDiffFile[];
|
||||
removed: UpdateDiffFile[];
|
||||
checkedAt: string;
|
||||
};
|
||||
|
||||
/** Outcome of a verify job, or extra instructions for a job (`removePaths` after an update). */
|
||||
export type JobResult = {
|
||||
checked?: number;
|
||||
missing?: string[];
|
||||
sizeMismatch?: string[];
|
||||
hashMismatch?: string[];
|
||||
/** Files in the model folder that aren't selected repo files. */
|
||||
extra?: { path: string; size: number; inRepo: boolean }[];
|
||||
/** Update jobs: files of the old revision to delete once the download succeeded. */
|
||||
removePaths?: string[];
|
||||
/** Delete jobs: files that were kept because they don't belong to the repo. */
|
||||
kept?: string[];
|
||||
};
|
||||
|
||||
export const models = sqliteTable(
|
||||
"models",
|
||||
{
|
||||
@@ -81,6 +105,8 @@ export const models = sqliteTable(
|
||||
hubState: text("hub_state", { enum: HUB_STATES }),
|
||||
/** When the repo or pinned commit was first seen missing; cleared when it's back. */
|
||||
hubMissingSince: ts("hub_missing_since"),
|
||||
/** What updating to `remoteSha` would change in the selection; null when up to date. */
|
||||
updateDiff: text("update_diff", { mode: "json" }).$type<UpdateDiff>(),
|
||||
lastVerifiedAt: ts("last_verified_at"),
|
||||
downloadedAt: ts("downloaded_at"),
|
||||
// Hub metadata (for search/filters), refreshed by the worker. Null until fetched.
|
||||
@@ -190,7 +216,7 @@ export const modelFiles = sqliteTable(
|
||||
// Jobs (executed by the worker)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const JOB_KINDS = ["download", "verify", "deep_verify"] as const;
|
||||
export const JOB_KINDS = ["download", "verify", "deep_verify", "delete"] as const;
|
||||
export type JobKind = (typeof JOB_KINDS)[number];
|
||||
|
||||
export const JOB_PURPOSES = ["initial", "add", "import", "repair", "update"] as const;
|
||||
@@ -239,6 +265,7 @@ export const jobs = sqliteTable(
|
||||
exitCode: integer("exit_code"),
|
||||
errorCode: text("error_code", { enum: JOB_ERROR_CODES }),
|
||||
errorMessage: text("error_message"),
|
||||
result: text("result", { mode: "json" }).$type<JobResult>(),
|
||||
/** Set by the web app; the worker picks it up and stops the job. */
|
||||
cancelRequestedAt: ts("cancel_requested_at"),
|
||||
startedAt: ts("started_at"),
|
||||
|
||||
Reference in new issue
Block a user