From 004ea43cf25e94f87e3a207a43b9282aa3854228 Mon Sep 17 00:00:00 2001 From: Jacob Schmidt Date: Thu, 26 Feb 2026 20:29:29 -0600 Subject: [PATCH] fix(tauri): recursively resolve Journal.Sidecar.exe path --- Journal.App/src-tauri/src/lib.rs | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Journal.App/src-tauri/src/lib.rs b/Journal.App/src-tauri/src/lib.rs index 1846b46..a0a673a 100644 --- a/Journal.App/src-tauri/src/lib.rs +++ b/Journal.App/src-tauri/src/lib.rs @@ -161,9 +161,49 @@ fn resolve_sidecar_path(root: &Path) -> Result { return Ok(release_path); } + let sidecar_root = root.join("Journal.Sidecar"); + if let Some(path) = find_sidecar_executable(&sidecar_root) { + return Ok(path); + } + Err("Journal.Sidecar.exe not found. Build Journal.Sidecar first.".to_string()) } +fn find_sidecar_executable(search_root: &Path) -> Option { + if !search_root.exists() { + return None; + } + + let mut stack = vec![search_root.to_path_buf()]; + while let Some(dir) = stack.pop() { + let Ok(entries) = fs::read_dir(&dir) else { + continue; + }; + + for entry in entries { + let Ok(entry) = entry else { + continue; + }; + let path = entry.path(); + if path.is_dir() { + stack.push(path); + continue; + } + + let is_sidecar_exe = path + .file_name() + .and_then(|name| name.to_str()) + .map(|name| name.eq_ignore_ascii_case("Journal.Sidecar.exe")) + .unwrap_or(false); + if is_sidecar_exe { + return Some(path); + } + } + } + + None +} + async fn send_with_managed_sidecar( state: &SidecarState, input_line: &str,