fix(app): fall back to default data folder when persisted path is stale - #8855
Open
santhiprakash wants to merge 1 commit into
Open
fix(app): fall back to default data folder when persisted path is stale#8855santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
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.
Describe Your Changes
resolve_jan_data_folder()(CLI/headless path) andget_app_configurations()(Tauri app path) so a persisteddata_folderthat no longer exists or is unreadable falls back to the default Jan data folder instead of returning the stale path.is_readable_data_folder()anddefault_data_folder_path_internal()helpers insrc-tauri/src/core/app/commands.rs.resolve_jan_data_folder) and the app path (get_app_configurations).JAN_DATA_FOLDERenvironment override as an explicit opt-in that is not validated or fallen back from.Fixes Issues
Self Checklist
data_folderfallbackcargo fmt -- src/core/app/commands.rsandcargo fmt --check -- src/core/app/commands.rs(clean)cargo clippy --lib(clean)cargo test --lib core::app::commandsProblem
After a macOS user home folder is renamed,
settings.jsonstill contains the old absolutedata_folder(e.g./Users/<oldname>/Library/Application Support/Jan/data). Bothresolve_jan_data_folder()andget_app_configurations()returned that path directly, so the app started against a non-existent directory and crashed.Triage
resolve_jan_data_folder()parsedconfig.data_folderand returned it with no existence/readability check.get_app_configurations()parsed the file and returned the storeddata_folderwithout validating it.Fix
Both read paths now call
is_readable_data_folder()on the persisteddata_folder. If it is missing or unreadable, they log a warning and fall back to the default Jan data folder. TheJAN_DATA_FOLDERenvironment override still takes precedence and is not validated.Verification
Before the fix, a stale absolute
data_folderreturned the stale path:After the fix, both new tests and the existing command tests pass:
Formatter:
cargo fmt -- src/core/app/commands.rsfollowed bycargo fmt --check -- src/core/app/commands.rsreturned no diff.Notes
settings.jsonon disk. The optional companion change to persist a tilde-based default path is left for a separate commit/PR as suggested in the issue.ENV_TEST_LOCKbecause they redirectXDG_DATA_HOME/XDG_CONFIG_HOME/HOME(for the CLI test) andAPP_NAME(for the Tauri test) while running in parallel with other tests.