fix(m1): inotify — use read_to_end for UTF-8 resilience, await spawn_blocking

- read_to_end + from_utf8_lossy replaces read_to_string so Wine/game logs
  with Latin-1 bytes are handled via U+FFFD replacement instead of silently
  dropping all events from that file
- bytes_read from I/O call used for new_pos (not content.len()) for correct
  byte position accounting
- spawn_blocking handle is now awaited so panics inside the blocking task
  surface to the caller instead of being silently swallowed
This commit is contained in:
pyr0ball 2026-05-18 17:25:30 -07:00
parent 7eaf22c130
commit 3c77969680

View file

@ -57,7 +57,9 @@ pub async fn watch(log_paths: HashMap<String, String>, tx: mpsc::Sender<SystemEv
}
}
}
});
})
.await
.ok();
}
pub fn expand_tilde(path: &str) -> String {
@ -77,9 +79,10 @@ pub fn read_new_lines(path: &str, from_byte: u64) -> (Vec<String>, u64) {
if file.seek(std::io::SeekFrom::Start(from_byte)).is_err() {
return (vec![], from_byte);
}
let mut content = String::new();
let _ = file.read_to_string(&mut content);
let new_pos = from_byte + content.len() as u64;
let mut raw = Vec::new();
let bytes_read = file.read_to_end(&mut raw).unwrap_or(0);
let content = String::from_utf8_lossy(&raw).into_owned();
let new_pos = from_byte + bytes_read as u64;
let lines: Vec<String> = content
.lines()
.filter(|l| !l.is_empty())