fix(m1): move mut rx inside async block (clippy), log+continue on parse errors in load()

This commit is contained in:
pyr0ball 2026-05-18 18:22:50 -07:00
parent 2706b2367d
commit c3958553a5
2 changed files with 24 additions and 16 deletions

View file

@ -51,11 +51,12 @@ pub fn run() {
.map(|pf| pf.log_paths.clone())
.unwrap_or_default();
let mut rx = watcher::spawn(log_paths);
let rx = watcher::spawn(log_paths);
let pf = Arc::new(pattern_file);
let app_handle = app.handle().clone();
tauri::async_runtime::spawn(async move {
let mut rx = rx;
while let Some(event) = rx.recv().await {
if let Some(ref pf) = *pf {
if let Some(matched) = patterns::classify(&event, pf) {

View file

@ -50,9 +50,17 @@ pub fn load(source_os: &str, distro_family: &str) -> Result<PatternFile> {
format!("/usr/share/robin/patterns/{filename}"),
];
for path in &candidates {
if let Ok(content) = std::fs::read_to_string(path) {
let pf: PatternFile =
toml::from_str(&content).with_context(|| format!("failed to parse {path}"))?;
let content = match std::fs::read_to_string(path) {
Ok(c) => c,
Err(_) => continue,
};
let pf: PatternFile = match toml::from_str(&content) {
Ok(p) => p,
Err(e) => {
log::warn!("patterns: failed to parse {path}: {e}");
continue;
}
};
for p in &pf.patterns {
anyhow::ensure!(
!p.match_text.is_empty(),
@ -67,7 +75,6 @@ pub fn load(source_os: &str, distro_family: &str) -> Result<PatternFile> {
}
return Ok(pf);
}
}
anyhow::bail!("pattern file not found: {filename}")
}