Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(now consistent with data_dir() behavior across all platforms)