fix(tauri): recursively resolve Journal.Sidecar.exe path
This commit is contained in:
parent
1e28ae9e25
commit
004ea43cf2
@ -161,9 +161,49 @@ fn resolve_sidecar_path(root: &Path) -> Result<PathBuf, String> {
|
||||
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<PathBuf> {
|
||||
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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user