fix(tauri): handle non-UTF-8 paths in default_data_folder_path#7577
Merged
Vanalite merged 2 commits intojanhq:mainfrom Mar 5, 2026
Merged
fix(tauri): handle non-UTF-8 paths in default_data_folder_path#7577Vanalite merged 2 commits intojanhq:mainfrom
Vanalite merged 2 commits intojanhq:mainfrom
Conversation
Replace panicking unwrap() calls with safe alternatives: - data_dir().unwrap() -> unwrap_or_else with home directory fallback - path.to_str().unwrap() -> path.to_string_lossy() for non-UTF-8 safety - Remove duplicate to_str() call by reusing path_str variable Fixes janhq#7572
Contributor
|
Thank you @eren-karakus0 |
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.
Summary
unwrap()calls indefault_data_folder_pathwith safe alternatives to prevent runtime crashes when the system data directory path contains non-UTF-8 characters.data_dir().unwrap()replaced withunwrap_or_elseusing home directory fallback (consistent withget_configuration_file_pathpattern)path.to_str().unwrap()replaced withpath.to_string_lossy()which substitutes invalid UTF-8 sequences with the Unicode replacement character instead of panickingto_str()call by reusing thepath_strvariableFixes #7572
Changes
src-tauri/src/core/app/commands.rs: 3 unwrap() calls replaced with safe alternatives indefault_data_folder_pathTest plan
data_dir()failure gracefully falls back to home directoryto_string_lossy()instead of panic.ai.appsuffix stripping logic preservedcargo fmtpasses