Skip to content

fix(cache): resolve app_dir path issue and unify cache directory handling#77

Merged
umpire274 merged 5 commits intomainfrom
v0.5.5
Nov 7, 2025
Merged

fix(cache): resolve app_dir path issue and unify cache directory handling#77
umpire274 merged 5 commits intomainfrom
v0.5.5

Conversation

@umpire274
Copy link
Owner

  • Fixed incorrect cache path resolution when using app_dir() on Linux and macOS
    (now consistent with data_dir() behavior across all platforms)
  • Added ensure_cache_dir() helper to centralize cache directory creation logic
  • Removed duplicated fs::create_dir_all() code from save_last_cache() and save_last_cache_json()
  • Improved reliability of cache read/write operations in clean or CI environments

…ling

- Fixed incorrect cache path resolution when using app_dir() on Linux and macOS
  (now consistent with data_dir() behavior across all platforms)
- Added ensure_cache_dir() helper to centralize cache directory creation logic
- Removed duplicated fs::create_dir_all() code from save_last_cache() and save_last_cache_json()
- Improved reliability of cache read/write operations in clean or CI environments
…test

- Use advisory file locks (fs2) to protect concurrent access in save_last_cache and load_last_cache.
- Implement atomic writes for the shared JSON store (last_quotes.json): write to a temporary file in the same directory and rename to replace the store.
- Uniformize cache path logic to use config::app_dir() (get_cache_path and cache_store_path).
- Add integration test tests/cache_tests.rs that exercises save/load roundtrip using config::set_app_dir_for_tests.
- Add fs2 = "0.4" dependency to Cargo.toml.
…add tests & docs

- Implement atomic writes for the shared JSON cache (last_quotes.json) by writing to a temporary file and replacing via rename (with a Windows remove+rename fallback for older semantics).
- Add advisory file locking using fs2 to protect concurrent access; extracted open_and_lock() helper to centralize locking logic.
- Switch internal cache helpers to anyhow::Result for richer error context and improved diagnostics.
- Unify cache path handling to use config::app_dir() and ensure cache directory creation via ensure_cache_dir().
- Add integration test tests/cache_tests.rs that validates save/load roundtrip in a sandboxed app dir.
- Update documentation: README.md and CHANGELOG.md reflecting the above changes.
- Add new dependencies in Cargo.toml: fs2 and anyhow.
All tests pass locally.
@umpire274 umpire274 merged commit d71503e into main Nov 7, 2025
1 check passed
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