@velvetmonkey/flywheel-memory 2.5.11 → 2.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +19 -14
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -27630,20 +27630,6 @@ async function initializeVault(name, vaultPathArg) {
27630
27630
  try {
27631
27631
  ctx.stateDb = openStateDb(vaultPathArg);
27632
27632
  serverLog("statedb", `[${name}] StateDb initialized`);
27633
- const integrity = checkDbIntegrity2(ctx.stateDb.db);
27634
- if (integrity.ok) {
27635
- safeBackupAsync2(ctx.stateDb.db, ctx.stateDb.dbPath).catch((err) => {
27636
- serverLog("backup", `[${name}] Safe backup failed: ${err}`, "error");
27637
- });
27638
- } else {
27639
- serverLog("statedb", `[${name}] Integrity check failed: ${integrity.detail} \u2014 recreating`, "error");
27640
- const dbPath = ctx.stateDb.dbPath;
27641
- preserveCorruptedDb(dbPath);
27642
- ctx.stateDb.close();
27643
- deleteStateDbFiles(dbPath);
27644
- ctx.stateDb = openStateDb(vaultPathArg);
27645
- attemptSalvage(ctx.stateDb.db, dbPath);
27646
- }
27647
27633
  const vaultInitRow = ctx.stateDb.getMetadataValue.get("vault_init_last_run_at");
27648
27634
  if (!vaultInitRow) {
27649
27635
  serverLog("server", `[${name}] Vault not initialized \u2014 call vault_init to enrich legacy notes`);
@@ -27944,6 +27930,25 @@ async function main() {
27944
27930
  });
27945
27931
  }
27946
27932
  const primaryCtx = vaultRegistry.getContext();
27933
+ if (primaryCtx.stateDb) {
27934
+ const integrity = checkDbIntegrity2(primaryCtx.stateDb.db);
27935
+ if (integrity.ok) {
27936
+ safeBackupAsync2(primaryCtx.stateDb.db, primaryCtx.stateDb.dbPath).catch((err) => {
27937
+ serverLog("backup", `[${primaryCtx.name}] Safe backup failed: ${err}`, "error");
27938
+ });
27939
+ } else {
27940
+ serverLog("statedb", `[${primaryCtx.name}] Integrity check failed: ${integrity.detail} \u2014 recreating`, "error");
27941
+ const dbPath = primaryCtx.stateDb.dbPath;
27942
+ preserveCorruptedDb(dbPath);
27943
+ primaryCtx.stateDb.close();
27944
+ deleteStateDbFiles(dbPath);
27945
+ primaryCtx.stateDb = openStateDb(primaryCtx.vaultPath);
27946
+ attemptSalvage(primaryCtx.stateDb.db, dbPath);
27947
+ stateDb = primaryCtx.stateDb;
27948
+ activateVault(primaryCtx, true);
27949
+ }
27950
+ serverLog("statedb", `[${primaryCtx.name}] Integrity check passed in ${Date.now() - startTime}ms`);
27951
+ }
27947
27952
  loadVaultCooccurrence(primaryCtx);
27948
27953
  activateVault(primaryCtx);
27949
27954
  await bootVault(primaryCtx, startTime);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velvetmonkey/flywheel-memory",
3
- "version": "2.5.11",
3
+ "version": "2.5.12",
4
4
  "description": "MCP tools that search, write, and auto-link your Obsidian vault — and learn from your edits.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -55,7 +55,7 @@
55
55
  "dependencies": {
56
56
  "@huggingface/transformers": "^3.8.1",
57
57
  "@modelcontextprotocol/sdk": "^1.26.0",
58
- "@velvetmonkey/vault-core": "^2.5.11",
58
+ "@velvetmonkey/vault-core": "^2.5.12",
59
59
  "better-sqlite3": "^12.0.0",
60
60
  "chokidar": "^4.0.0",
61
61
  "gray-matter": "^4.0.3",