|
|
@@ -2276,6 +2276,7 @@ function parseCLI() {
|
|
|
"embed-batch-size": { type: "string" }, // Batch size for HTTP provider
|
|
|
"embed-timeout-ms": { type: "string" }, // Per-request timeout
|
|
|
"embed-auto-fallback": { type: "boolean" }, // Wrap openai in AutoFallback (local fallback)
|
|
|
+ "no-vacuum": { type: "boolean" }, // cleanup: skip VACUUM for cron-safe pruning
|
|
|
// Update options
|
|
|
pull: { type: "boolean" }, // git pull before update
|
|
|
refresh: { type: "boolean" },
|
|
|
@@ -2494,7 +2495,7 @@ function showHelp() {
|
|
|
console.log(" --embed-batch-size <n> - Batch size for HTTP provider (default: 64)");
|
|
|
console.log(" --embed-timeout-ms <n> - Per-request timeout in ms (default: 30000)");
|
|
|
console.log(" --embed-auto-fallback - Wrap openai provider in local fallback (or QMD_EMBED_AUTO_FALLBACK)");
|
|
|
- console.log(" qmd cleanup - Clear caches, vacuum DB");
|
|
|
+ console.log(" qmd cleanup [--no-vacuum] - Clear caches and orphaned data; VACUUM unless --no-vacuum");
|
|
|
console.log("");
|
|
|
console.log("Query syntax (qmd query):");
|
|
|
console.log(" QMD queries are either a single expand query (no prefix) or a multi-line");
|
|
|
@@ -3089,6 +3090,7 @@ if (isMain) {
|
|
|
}
|
|
|
case "cleanup": {
|
|
|
const db = getDb();
|
|
|
+ const skipVacuum = !!cli.values["no-vacuum"];
|
|
|
// 1. Clear llm_cache
|
|
|
const cacheCount = deleteLLMCache(db);
|
|
|
console.log(`${c.green}✓${c.reset} Cleared ${cacheCount} cached API responses`);
|
|
|
@@ -3105,9 +3107,14 @@ if (isMain) {
|
|
|
if (inactiveDocs > 0) {
|
|
|
console.log(`${c.green}✓${c.reset} Removed ${inactiveDocs} inactive document records`);
|
|
|
}
|
|
|
- // 4. Vacuum to reclaim space
|
|
|
- vacuumDatabase(db);
|
|
|
- console.log(`${c.green}✓${c.reset} Database vacuumed`);
|
|
|
+ // 4. Vacuum to reclaim space unless this is a lightweight cron prune.
|
|
|
+ if (skipVacuum) {
|
|
|
+ console.log(`${c.dim}Skipped VACUUM (--no-vacuum)${c.reset}`);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ vacuumDatabase(db);
|
|
|
+ console.log(`${c.green}✓${c.reset} Database vacuumed`);
|
|
|
+ }
|
|
|
closeDb();
|
|
|
break;
|
|
|
}
|