Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions apps/desktop/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ url = "2"
percent-encoding = "2"
tauri-plugin-os = "2.3.1"
tauri-plugin-store = "2.4.0"
rust-ini = "0.20"


[dev-dependencies]
tempfile = "3.13.0"
Expand Down
63 changes: 56 additions & 7 deletions apps/desktop/src-tauri/src/browser_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,70 @@ pub fn get_chrome_profiles(
}

pub fn get_firefox_profiles() -> Result<Vec<ProfileDescriptor>, Box<dyn std::error::Error>> {
use std::path::PathBuf;
use ini::Ini;
Comment on lines 175 to +177

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Import uses undeclared crate

The Firefox profile parsing code imports ini::Ini, but the new dependency was added under the name rust-ini in Cargo.toml. Because Cargo exposes the crate as rust_ini by default, the module ini does not exist and the project fails to compile. Rename the dependency to ini (or alias it) or change the import to rust_ini::Ini so the code builds.

Useful? React with 👍 / 👎.


let os_type = tauri_plugin_os::type_();
let base_dir = match os_type {
OsType::Windows | OsType::Macos => data_local_dir(),
OsType::Linux => home_dir(),
_ => None,
};

if let Some(mut path) = base_dir {
if let Some(mut base_path) = base_dir {
match os_type {
OsType::Windows => path.push("Mozilla\\Firefox\\Profiles"),
OsType::Macos => path.push("Firefox/Profiles"),
OsType::Linux => path.push(".mozilla/firefox"),
OsType::Windows => base_path.push("Mozilla\\Firefox"),
OsType::Macos => base_path.push("Firefox"),
OsType::Linux => base_path.push(".mozilla/firefox"),
_ => return Ok(Vec::new()),
}

if path.exists() {
match fs::read_dir(path) {
let ini_path = base_path.join("profiles.ini");

if ini_path.exists() {
let conf = Ini::load_from_file(&ini_path)?;
let mut profiles: Vec<ProfileDescriptor> = Vec::new();

for (section_name, properties) in &conf {
if let Some(section) = section_name {
if section.starts_with("Profile") {
let name = properties.get("Name").map(|s| s.to_string());
let path_str = properties.get("Path").map(|s| s.to_string());
let is_relative = properties
.get("IsRelative")
.map(|s| s == "1")
.unwrap_or(true);

if let Some(p) = path_str {
let path = if is_relative {
base_path.join(&p)
} else {
PathBuf::from(&p)
};

let display_name = name.unwrap_or_else(|| {
path.file_name()
.unwrap_or_default()
.to_string_lossy()
.to_string()
});

profiles.push(ProfileDescriptor {
display_name,
directory: path.to_string_lossy().to_string(),
});
}
}
}
}

profiles.sort_by(|a, b| a.display_name.cmp(&b.display_name));
return Ok(profiles);
}

let profiles_path = base_path.join("Profiles");
if profiles_path.exists() {
match fs::read_dir(profiles_path) {
Ok(entries) => {
let mut profiles: Vec<ProfileDescriptor> = entries
.filter_map(Result::ok)
Expand All @@ -204,6 +251,7 @@ pub fn get_firefox_profiles() -> Result<Vec<ProfileDescriptor>, Box<dyn std::err
_ => None,
})
.collect();

profiles.sort_by(|a, b| a.display_name.cmp(&b.display_name));
return Ok(profiles);
}
Expand All @@ -215,5 +263,6 @@ pub fn get_firefox_profiles() -> Result<Vec<ProfileDescriptor>, Box<dyn std::err
}
}

return Ok(Vec::new());
Ok(Vec::new())
}

Loading