Every bot file was chunked into bot_file_chunks and embedded into bot_file_vectors, and uploads kept their extracted text in media.text_content, which together took most of the database. Bot files are no longer indexed: bots find them by name or path with list_files and read them with read_file, and search_files, ingest_file and the files modal's re-read button are gone. Attachments keep no text; a reply reads a document from the file. Only knowledgebase documents keep text. The schema drops both tables and the ingest columns. At boot, dropStoredFileText removes what older versions stored (file jobs, upload text) and vacuums once much of the database is free. The media:prune-text script it replaces is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
25 lines
979 B
TypeScript
25 lines
979 B
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { AppData } from "@/src/data/app-data";
|
|
import shouldVacuum from "./should-vacuum";
|
|
|
|
const page_size = 4096;
|
|
const min_pages = Math.ceil(AppData.DbVacuumMinFreeBytes / page_size);
|
|
|
|
describe("shouldVacuum", () => {
|
|
test("vacuums when a large share of a big file is free", () => {
|
|
expect(shouldVacuum({ page_count: min_pages * 2, freelist_count: min_pages, page_size })).toBe(true);
|
|
});
|
|
|
|
test("leaves a database with little free space alone", () => {
|
|
expect(shouldVacuum({ page_count: min_pages * 100, freelist_count: min_pages, page_size })).toBe(false);
|
|
});
|
|
|
|
test("leaves a small database alone even when mostly free", () => {
|
|
expect(shouldVacuum({ page_count: 20, freelist_count: 15, page_size })).toBe(false);
|
|
});
|
|
|
|
test("never vacuums on missing numbers", () => {
|
|
expect(shouldVacuum({ page_count: 0, freelist_count: 0, page_size })).toBe(false);
|
|
});
|
|
});
|