Skip to content

feat(storage): support BLOGWATCHER_DB override#9

Open
maciej wants to merge 1 commit intoHyaxia:mainfrom
maciej:codex/blogwatcher-db-override
Open

feat(storage): support BLOGWATCHER_DB override#9
maciej wants to merge 1 commit intoHyaxia:mainfrom
maciej:codex/blogwatcher-db-override

Conversation

@maciej
Copy link
Copy Markdown

@maciej maciej commented Mar 2, 2026

Why

Blogwatcher currently stores everything in a single ~/.blogwatcher/blogwatcher.db.

That makes isolation between independent blog lists difficult and increases risk for broad operations like read-all (including agent-driven usage), where one context can accidentally affect another.

What changed

  • Added BLOGWATCHER_DB as a default DB path override.
  • DefaultDBPath() now:
    • uses BLOGWATCHER_DB when it is set to a non-empty value
    • falls back to ~/.blogwatcher/blogwatcher.db when unset/empty
  • Kept CLI behavior unchanged (OpenDatabase("") still works across commands; it now resolves through the env-aware default path).
  • Updated docs to describe the override and isolation use case.

Tests

  • Added TestDefaultDBPathUsesEnvOverride
  • Added TestDefaultDBPathFallsBackWhenEnvIsEmpty
  • Verified go test ./...

Smoke test

Validated against:

Using isolated DB path:

  • BLOGWATCHER_DB=/tmp/blogwatcher-smoke.db ... add
  • ... scan
  • ... articles --all

Observed 2 release entries (v0.0.2, v0.0.1) stored in the isolated DB, and a separate DB path showed no shared articles.

Backward compatibility

No breaking change: if BLOGWATCHER_DB is not set (or empty), behavior remains unchanged.

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