Skip to content

feat(mcp): prefer pre-decrypted DB files in DBCache.get#145

Open
thedavidweng wants to merge 1 commit into
ylytdeng:mainfrom
thedavidweng:feat/mcp-prefer-decrypted-db
Open

feat(mcp): prefer pre-decrypted DB files in DBCache.get#145
thedavidweng wants to merge 1 commit into
ylytdeng:mainfrom
thedavidweng:feat/mcp-prefer-decrypted-db

Conversation

@thedavidweng

Copy link
Copy Markdown
Contributor

Summary

DBCache.get() now checks decrypted/<rel_path> first. If a pre-decrypted copy exists and opens cleanly (SELECT 1), MCP tools use it directly instead of decrypting from db_storage on every access.

Falls back to the existing on-the-fly decrypt + WAL merge path when the decrypted file is missing or corrupt.

Motivation

Users who already ran decrypt_db.py have plaintext copies under decrypted/. Re-decrypting on each MCP query is slower and redundant.

Test plan

  • With decrypted/contact/contact.db present, MCP get_contacts returns results without touching encrypted DB
  • With decrypted/ missing or corrupt, behavior unchanged (falls back to decrypt path)
  • Stale decrypted copy: if encrypted DB is newer, existing mtime cache still re-decrypts via tmp path (pre-decrypted shortcut only applies when file exists and is valid SQLite)

When decrypted/<rel_path> already exists and opens cleanly, use it
directly instead of re-decrypting from the encrypted db_storage copy.
Falls back to the existing on-the-fly decrypt path when missing or corrupt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant