Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

fix: add check for portable mode and set environment variables accordingly

Tonho8e25d7ab9c77
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 5481eca2..1aaf54b2 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -1,10 +1,23 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
+fn check_portable_mode() {
+ if let Ok(exe) = std::env::current_exe() {
+ if let Some(dir) = exe.parent() {
+ if dir.join("portable.txt").exists() || dir.join(".portable").exists() {
+ let data_dir = dir.join("data");
+ let _ = std::fs::create_dir_all(&data_dir);
+ std::env::set_var("OMNIGET_PORTABLE", "1");
+ std::env::set_var("OMNIGET_DATA_DIR", data_dir.to_string_lossy().to_string());
+ }
+ }
+ }
+}
+
fn setup_environment() {
std::env::remove_var("PYTHONHOME");
std::env::remove_var("PYTHONPATH");
- if let Some(bin_dir) = dirs::data_dir().map(|d| d.join("omniget").join("bin")) {
+ if let Some(bin_dir) = omniget_lib::core::paths::app_data_dir().map(|d| d.join("bin")) {
let sep = if cfg!(windows) { ";" } else { ":" };
let current = std::env::var("PATH").unwrap_or_default();
std::env::set_var("PATH", format!("{}{}{}", bin_dir.display(), sep, current));
@@ -15,6 +28,7 @@ fn setup_environment() {
}
fn main() {
+ check_portable_mode();
setup_environment();
omniget_lib::run()
}