-
Notifications
You must be signed in to change notification settings - Fork 321
implement: Portable Mode #4171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
implement: Portable Mode #4171
Conversation
Centralizes portable mode detection and setup to ensure consistent behavior across the application, especially for the window state plugin and directory lookups. This change introduces a `setup_portable_env_vars` function that sets environment variables based on the detected portable directory. It ensures that `tauri-plugin-window-state` and `dirs.rs` correctly use the portable directory for storing application data and configuration. The logic for detecting portable mode has been moved to `DirectoryInfo`. The `is_portable` command in `main.rs` now utilizes the centralized portable directory check. The portable mode detection logic has been removed from `DirectoryInfo::get_initial_settings_dir` and `is_portable` to prevent duplicated checks.
Unifies portable mode detection logic into a single function and reuses it across the application. This ensures consistency in determining whether the application is running in portable mode, particularly for setting environment variables and checking portable status.
Hi @AlexTMjugador and @Gaming32, now everything should work fine, i have done a little workaround for doing that, at the start i changed dirs.rs but some files was hardcoded by some tauri plugins at appdata soo i made a workaround that change the env from where tauri store files depending on the operating system. Everything should work well now. I hope this workaround can be accepted cause its a clean workaround and not only simplify things, it helps to not need to adapt any code if new directory or something is added. |
…and setting process environment variables for portable data directory
…e setup and directory checks
…mode to use unsafe blocks
Signed-off-by: MiguVT <71216796+MiguVT@users.noreply.github.com>
Signed-off-by: MiguVT <71216796+MiguVT@users.noreply.github.com>
That's a very welcome PR to see! Though, I have to wonder about a few things:
|
No, there willnt be any risk but I prefer mantain it in a subdir allowing more easy migration.
Will research that, I didnt know that variable exist, its cool to know that :) |
Refactors portable mode detection and initialization. - Simplifies portable mode enablement to rely solely on the presence of `portable.txt`. - Removes environment variable method for enabling portable mode. - Ensures portable environment is set up as early as possible in the application lifecycle. - Sets `THESEUS_CONFIG_DIR` environment variable when in portable mode, ensuring consistent data directory usage across components. - Updates documentation to reflect the simplified portable mode activation. - Fixes window state location when using portable mode.
Refactors portable mode detection to use a dedicated command and improves reliability. This change introduces a `is_portable_mode` command in Rust to check for portable mode, replacing the previous inline check. It also fixes an issue where the portable mode was not being correctly detected in the frontend, potentially leading to window state saving in portable mode. The Vue component now calls the new tauri command.
Marking as ready for review.
Ready for feedback! :D |
Hi, any update? @AlexTMjugador @Gaming32 ???? |
This pull request adds support for a "portable mode" to the Modrinth App, allowing users to run the application from any location with all data stored alongside the executable. The implementation includes both backend and documentation updates to detect and describe portable mode activation via either an environment variable or a
portable.txt
file.Portable Mode Implementation:
DirectoryInfo
by checking for theMODRINTH_PORTABLE
environment variable or the presence of aportable.txt
file next to the executable. When enabled, all app data is stored in aModrinthAppData
directory beside the executable.API and Command Updates:
is_portable
inmain.rs
to expose portable mode status to the frontend, and registered it in the app’s invoke handler. [1] [2]Documentation:
portable-mode.md
), including activation methods, directory structure, use cases, conversion instructions, troubleshooting, and security considerations.