Import folders without a Hub repo as local models

The Import form gets "Add as local model": every file in the folder,
kept as it is, named after the folder. A new models.source column
(hub | local) marks them; local models skip Hub checks, metadata,
downloads, updates and deep verify, and Verify checks existence and
size only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-11-08 00:14:56 +01:00
1 parent 90d6007b55
commit 80ccf800df
21 files changed
+1747 -39

No files matched your search

+3 -2
View File
@@ -10,12 +10,13 @@ import { HubError, listFiles, resolveRevision, SHA_RE } from "./client";
type CheckedModel = Pick<
typeof models.$inferSelect,
"id" | "repoId" | "pinnedSha" | "trackedRevision" | "hubMissingSince" | "updateDiff" | "includePatterns" | "excludePatterns"
"id" | "repoId" | "source" | "pinnedSha" | "trackedRevision" | "hubMissingSince" | "updateDiff" | "includePatterns" | "excludePatterns"
>;
const CHECKED_COLUMNS = {
id: models.id,
repoId: models.repoId,
source: models.source,
pinnedSha: models.pinnedSha,
trackedRevision: models.trackedRevision,
hubMissingSince: models.hubMissingSince,
@@ -128,7 +129,7 @@ export async function modelsDueForHubCheck(intervalMs: number, limit = 50): Prom
return db()
.select(CHECKED_COLUMNS)
.from(models)
.where(or(isNull(models.lastCheckedAt), lt(models.lastCheckedAt, cutoff)))
.where(and(eq(models.source, "hub"), or(isNull(models.lastCheckedAt), lt(models.lastCheckedAt, cutoff))))
.orderBy(asc(models.lastCheckedAt))
.limit(limit);
}
+2 -2
View File
@@ -1,4 +1,4 @@
import { eq, isNull } from "drizzle-orm";
import { and, eq, isNull } from "drizzle-orm";
import { db } from "@/lib/db/client";
import { models } from "@/lib/db/schema";
import { getAuthorAvatar, getRepoInfo } from "./client";
@@ -26,7 +26,7 @@ export async function backfillMetadata(onError: (repoId: string, err: unknown) =
const missing = await db()
.select({ id: models.id, repoId: models.repoId, pinnedSha: models.pinnedSha })
.from(models)
.where(isNull(models.metadataFetchedAt));
.where(and(eq(models.source, "hub"), isNull(models.metadataFetchedAt)));
let updated = 0;
for (const m of missing) {
try {