Local models: Reload button, scans keep their files in step
Files tab → Reload asks the worker for a scan and waits until it has finished. Every scan now syncs local models' file lists with their folders (new, resized, removed files; README) and settles the status. Skipped while a job runs, and for a folder that is gone or too big. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f862717158
commit
80d71a1bc9
9 files changed
+218
-15
No files matched your search
@@ -89,4 +89,60 @@ describe("models folder scan", () => {
|
||||
writeFileSync(join(folder, "ReadMe.md"), "# Hello\n");
|
||||
assert.equal(await scan.readReadme(folder), "# Hello\n");
|
||||
});
|
||||
|
||||
it("diffs a local model's files against its folder", () => {
|
||||
const stored = [
|
||||
{ id: "1", path: "keep.gguf", size: 5, state: "present" },
|
||||
{ id: "2", path: "grown.gguf", size: 5, state: "present" },
|
||||
{ id: "3", path: "back.json", size: 2, state: "missing" },
|
||||
{ id: "4", path: "gone.json", size: 2, state: "present" },
|
||||
];
|
||||
const found = [
|
||||
{ path: "keep.gguf", size: 5 },
|
||||
{ path: "grown.gguf", size: 9 },
|
||||
{ path: "back.json", size: 2 },
|
||||
{ path: "new.md", size: 1 },
|
||||
];
|
||||
assert.deepEqual(scan.localFileChanges(stored, found), {
|
||||
insert: [{ path: "new.md", size: 1 }],
|
||||
update: [
|
||||
{ id: "2", size: 9 },
|
||||
{ id: "3", size: 2 },
|
||||
],
|
||||
remove: ["4"],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps a local model in step with its folder", async () => {
|
||||
const { eq } = await import("drizzle-orm");
|
||||
const d = D.db();
|
||||
const folder = join(modelsDir, "mine", "local");
|
||||
put(join(folder, "model.gguf"), 4);
|
||||
put(join(folder, "old.json"), 2);
|
||||
await d.insert(S.models).values({ id: "local1", repoId: "mine/local", source: "local", trackedRevision: "", pinnedSha: "", localPath: "mine/local", status: "ready" });
|
||||
await d.insert(S.modelFiles).values([
|
||||
{ modelId: "local1", path: "model.gguf", size: 4, selected: true, state: "present" },
|
||||
{ modelId: "local1", path: "old.json", size: 2, selected: true, state: "present" },
|
||||
]);
|
||||
|
||||
rmSync(join(folder, "old.json"));
|
||||
put(join(folder, "model.gguf"), 6);
|
||||
put(join(folder, "extra", "new.bin"), 3);
|
||||
writeFileSync(join(folder, "README.md"), "# Mine\n");
|
||||
await scan.scanModelsDir(modelsDir);
|
||||
|
||||
const files = await d.select().from(S.modelFiles).where(eq(S.modelFiles.modelId, "local1"));
|
||||
assert.deepEqual(
|
||||
files.map((f) => [f.path, f.size, f.state, f.selected]).sort(),
|
||||
[
|
||||
["README.md", 7, "present", true],
|
||||
["extra/new.bin", 3, "present", true],
|
||||
["model.gguf", 6, "present", true],
|
||||
],
|
||||
);
|
||||
const model = await d.query.models.findFirst({ where: eq(S.models.id, "local1") });
|
||||
assert.equal(model?.localReadme, "# Mine\n");
|
||||
assert.equal(model?.status, "ready");
|
||||
assert.equal((await stored())["mine/local"], undefined, "a model's folder is no import candidate");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user