Skip to content

Never write lazydiff.db to the current directory - #18

Merged
rs545837 merged 1 commit into
mainfrom
fix-db-path-cwd-fallback
Jul 3, 2026
Merged

Never write lazydiff.db to the current directory#18
rs545837 merged 1 commit into
mainfrom
fix-db-path-cwd-fallback

Conversation

@rs545837

@rs545837 rs545837 commented Jul 3, 2026

Copy link
Copy Markdown
Member

Fixes #17.

The database path fallback chain in review_store.rs ended in env::current_dir(). On systems where neither XDG_DATA_HOME nor HOME is set (typically Windows), that put lazydiff/lazydiff.db in whatever repo the user ran lazydiff from, easy to commit by accident.

This replaces xdg_data_home() with a platform-aware default_data_dir():

  • XDG_DATA_HOME if set (unchanged, so existing Unix installs keep their data)
  • Windows: LOCALAPPDATA, then USERPROFILE\AppData\Local
  • Unix: HOME/.local/share (unchanged)
  • Last resort: the OS temp dir, never the working directory

A stray database in the temp dir is recoverable; one committed into a user's repo is not.

The data-dir fallback chain ended in env::current_dir(), so on systems
without XDG_DATA_HOME or HOME set (typically Windows) the database
landed in whatever repo the user ran lazydiff from. Resolve the
platform data dir instead (LOCALAPPDATA/USERPROFILE on Windows) and
fall back to the temp dir, never the working directory.

Fixes #17. Thanks @ofek for the report.

@inspect-review inspect-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inspect review

Triage: 4 entities analyzed | 0 critical, 0 high, 3 medium, 1 low
Verdict: standard_review

Findings (0)


Reviewed by inspect | Entity-level triage found 0 high-risk changes

@rs545837
rs545837 merged commit bf8d6e6 into main Jul 3, 2026
4 checks passed
@rs545837
rs545837 deleted the fix-db-path-cwd-fallback branch July 3, 2026 01:20
@ofek

ofek commented Jul 3, 2026

Copy link
Copy Markdown

Thanks!

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.

Persistent data files

2 participants