xtask: Ignore non-text files in spec links check
This commit is contained in:
parent
2753577d02
commit
c652461ae7
@ -3,7 +3,7 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
io::{BufRead, BufReader},
|
io::{BufRead, BufReader, ErrorKind},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -85,7 +85,23 @@ fn collect_links(path: &Path) -> Result<Vec<SpecLink>> {
|
|||||||
let mut content = BufReader::new(File::open(path)?);
|
let mut content = BufReader::new(File::open(path)?);
|
||||||
|
|
||||||
// We can assume a spec link will never overflow to another line.
|
// We can assume a spec link will never overflow to another line.
|
||||||
while content.read_line(&mut buf)? > 0 {
|
loop {
|
||||||
|
match content.read_line(&mut buf) {
|
||||||
|
Ok(read) => {
|
||||||
|
if read == 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
if err.kind() == ErrorKind::InvalidData {
|
||||||
|
// The content is not UTF-8 text, skip.
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
return Err(err.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
line += 1;
|
line += 1;
|
||||||
|
|
||||||
// If for some reason a line has 2 spec links.
|
// If for some reason a line has 2 spec links.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user