From c8e1641896286a543feaa7c6726b70214bbc1149 Mon Sep 17 00:00:00 2001 From: Julian Freeman Date: Thu, 16 Apr 2026 19:27:48 -0400 Subject: [PATCH] fix bug --- src-tauri/src/scanner.rs | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src-tauri/src/scanner.rs b/src-tauri/src/scanner.rs index e755d7f..7e0b685 100644 --- a/src-tauri/src/scanner.rs +++ b/src-tauri/src/scanner.rs @@ -39,13 +39,7 @@ fn scan_browser(config: BrowserConfigEntry) -> Option { .and_then(|value| value.get("info_cache")) .and_then(Value::as_object); - let mut profile_ids = BTreeSet::new(); - collect_profile_ids_from_fs(&root, &mut profile_ids); - if let Some(cache) = profile_cache { - for profile_id in cache.keys() { - profile_ids.insert(profile_id.to_string()); - } - } + let profile_ids = collect_profile_ids_from_local_state(profile_cache); let mut profiles = Vec::new(); let mut extensions = BTreeMap::::new(); @@ -108,23 +102,12 @@ fn scan_browser(config: BrowserConfigEntry) -> Option { }) } -fn collect_profile_ids_from_fs(root: &Path, profile_ids: &mut BTreeSet) { - let Ok(entries) = fs::read_dir(root) else { - return; - }; - - for entry in entries.flatten() { - let Ok(file_type) = entry.file_type() else { - continue; - }; - if !file_type.is_dir() { - continue; - } - let name = entry.file_name().to_string_lossy().to_string(); - if name == "Default" || name.starts_with("Profile ") { - profile_ids.insert(name); - } - } +fn collect_profile_ids_from_local_state( + profile_cache: Option<&serde_json::Map>, +) -> BTreeSet { + profile_cache + .map(|cache| cache.keys().cloned().collect()) + .unwrap_or_default() } fn build_profile_summary(