Release 0.16.0: new look, search, remove files, easier deploy
Release / release (push) Successful in 4m33s
Release / release (push) Successful in 4m33s
- Dot-matrix "Creation of Adam" page banners behind a floating menu, glass cards and tables, library header with live stats, table toolbar with pagination, Cmd/Ctrl+K search across models, endpoints, runs, tags, settings and actions. - Remove single files from a model (selection + disk, via a worker job). - Containers start as root to prepare folders and drop to PUID:PGID; AUTH_SECRET is generated when unset; sandbox runs as nobody; KANAME_IMAGE and image docs in the README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c6bcb514e6
commit
5becfc47a0
53 files changed
+1869
-468
No files matched your search
@@ -231,3 +231,50 @@ export async function addFilesToModel(modelId: string, paths: string[]): Promise
|
||||
const { jobId } = await queueDownload(modelId, "add");
|
||||
return { jobId, added: changed.filter((f) => !f.selected).length };
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove files from a model: take them out of the selection rule (exact-path excludes, and their
|
||||
* exact includes dropped), mark them unselected, and queue a delete job that removes them from
|
||||
* disk. The model and its other files stay. Removing every selected file is refused: delete the
|
||||
* model instead.
|
||||
*/
|
||||
export async function removeFilesFromModel(modelId: string, paths: string[]): Promise<{ jobId: string; removed: number }> {
|
||||
const d = db();
|
||||
const model = await d.query.models.findFirst({ where: eq(models.id, modelId) });
|
||||
if (!model) throw new ModelError("not_found", "Model not found.", 404);
|
||||
if (await hasOpenJob(modelId)) throw new ModelError("busy", "A job for this model is still queued or running. Remove files when it has finished.", 409);
|
||||
|
||||
const files = await d.select().from(modelFiles).where(eq(modelFiles.modelId, modelId));
|
||||
const wanted = new Set(paths);
|
||||
const remove = files.filter((f) => f.selected && wanted.has(f.path));
|
||||
if (remove.length === 0) throw new ModelError("empty_selection", "None of these files is selected.", 400);
|
||||
if (remove.length === files.filter((f) => f.selected).length) {
|
||||
throw new ModelError("empty_selection", "That would remove every file of this model. Delete the model instead.", 400);
|
||||
}
|
||||
|
||||
const exact = new Set(remove.map((f) => escapeGlob(f.path)));
|
||||
// Drop the files' exact includes; files a broader pattern still selects get an exact exclude.
|
||||
const include = model.includePatterns.filter((p) => !exact.has(p));
|
||||
const stillSelected = remove.filter((f) => isSelected(f.path, { include, exclude: model.excludePatterns }));
|
||||
const rule: SelectionRule = { include, exclude: [...model.excludePatterns, ...stillSelected.map((f) => escapeGlob(f.path))] };
|
||||
// The rule must now select exactly the old selection minus these files.
|
||||
const changed = files.filter((f) => f.selected !== isSelected(f.path, rule));
|
||||
if (changed.some((f) => !wanted.has(f.path))) throw new ModelError("busy", "The selection rule couldn't be narrowed to just these files.", 409);
|
||||
|
||||
const jobId = ulid();
|
||||
await d.batch([
|
||||
// The selection changed, so a stored update diff is stale; the next Hub check recomputes it.
|
||||
d.update(models).set({ includePatterns: rule.include, excludePatterns: rule.exclude, updateDiff: null }).where(eq(models.id, modelId)),
|
||||
...remove.map((f) => d.update(modelFiles).set({ selected: false }).where(eq(modelFiles.id, f.id))),
|
||||
d.insert(jobs).values({
|
||||
id: jobId,
|
||||
modelId,
|
||||
kind: "delete",
|
||||
purpose: "remove",
|
||||
targetSha: model.pinnedSha,
|
||||
totalBytes: remove.reduce((s, f) => s + f.size, 0),
|
||||
result: { removePaths: remove.map((f) => f.path) },
|
||||
}),
|
||||
]);
|
||||
return { jobId, removed: remove.length };
|
||||
}
|
||||
Reference in new issue
Block a user