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
@@ -109,3 +109,31 @@ export async function bytesOnDisk(
|
||||
}
|
||||
return { done: Math.min(partial, file.size), complete: false };
|
||||
}
|
||||
|
||||
/** Delete a downloaded file and hf's metadata/lock for it, so the next `hf download` fetches it again. */
|
||||
export async function removeLocalFile(dir: string, path: string): Promise<boolean> {
|
||||
const full = join(dir, path);
|
||||
const existed = (await fileSize(full)) != null;
|
||||
await rm(full, { force: true });
|
||||
await rm(join(dir, DOWNLOAD_DIR, `${path}.metadata`), { force: true });
|
||||
await rm(join(dir, DOWNLOAD_DIR, `${path}.lock`), { force: true });
|
||||
return existed;
|
||||
}
|
||||
|
||||
/** All files under `dir` (relative, "/"-separated), skipping hf's .cache and .git folders. */
|
||||
export async function listLocalFiles(dir: string): Promise<{ path: string; size: number }[]> {
|
||||
let entries;
|
||||
try {
|
||||
entries = await readdir(dir, { recursive: true, withFileTypes: true });
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
const out: { path: string; size: number }[] = [];
|
||||
for (const e of entries) {
|
||||
if (!e.isFile()) continue;
|
||||
const rel = join(e.parentPath, e.name).slice(dir.length + 1).split(sep).join("/");
|
||||
if (rel.startsWith(".cache/") || rel.startsWith(".git/")) continue;
|
||||
out.push({ path: rel, size: (await fileSize(join(dir, rel))) ?? 0 });
|
||||
}
|
||||
return out.sort((a, b) => a.path.localeCompare(b.path));
|
||||
}
|
||||
Reference in new issue
Block a user