Merge pull request #94 from Miyabi-G-K/feature/issue-91-obsidian-utf8-fix
fix(protocol): handle non-UTF-8 in Obsidian vault
This commit is contained in:
commit
2733aa9552
1 changed files with 7 additions and 1 deletions
8
crates/miyabi-core/src/protocol.rs
generated
8
crates/miyabi-core/src/protocol.rs
generated
|
|
@ -1241,7 +1241,13 @@ fn read_file_snippet(path: &Path, max_lines: usize) -> Result<String, Error> {
|
|||
let reader = BufReader::new(file);
|
||||
let mut lines = Vec::new();
|
||||
for line in reader.lines().take(max_lines) {
|
||||
lines.push(line?);
|
||||
match line {
|
||||
Ok(l) => lines.push(l),
|
||||
Err(_) => {
|
||||
// Non-UTF-8 file (binary) — return what we have so far
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(lines.join("\n"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue