pull/132/head
Tomas Janousek 2 years ago
parent 6eb090b839
commit 45b7b7ae6f

@ -158,7 +158,10 @@ impl Read for ReadErr {
}
}*/
pub fn postproc_encoding<'a, R: Read+'a>(line_prefix: &str, inp: R) -> Result<Box<dyn Read + 'a>> {
pub fn postproc_encoding<'a, R: Read + 'a>(
line_prefix: &str,
inp: R,
) -> Result<Box<dyn Read + 'a>> {
// TODO: parse these options from ripgrep's configuration
let encoding = None; // detect bom but usually assume utf8
let bom_sniffing = true;
@ -184,9 +187,7 @@ pub fn postproc_encoding<'a, R: Read+'a>(line_prefix: &str, inp: R) -> Result<Bo
if fourk.contains(&0u8) {
log::debug!("detected binary");
let v = "[rga: binary data]";
return Ok(Box::new(std::io::Cursor::new(
v
)));
return Ok(Box::new(std::io::Cursor::new(v)));
/*let err = std::io::Error::new(
std::io::ErrorKind::InvalidData,
format!("{}[rga: binary data]", line_prefix),
@ -280,7 +281,12 @@ mod tests {
test_from_strs(false, "foo.pdf:", inp, oup)?;
test_from_strs(false, "foo:", "this is a test \n\n \0 foo", "foo:[rga: binary data]")?;
test_from_strs(
false,
"foo:",
"this is a test \n\n \0 foo",
"foo:[rga: binary data]",
)?;
test_from_strs(false, "foo:", "\0", "foo:[rga: binary data]")?;
Ok(())

@ -21,7 +21,9 @@ pub trait PreprocCache: Send + Sync {
}
/// opens a LMDB cache
fn open_cache_db(path: &Path) -> Result<std::sync::Arc<std::sync::RwLock<rkv::Rkv<LmdbEnvironment>>>> {
fn open_cache_db(
path: &Path,
) -> Result<std::sync::Arc<std::sync::RwLock<rkv::Rkv<LmdbEnvironment>>>> {
std::fs::create_dir_all(path)?;
use rkv::backend::LmdbEnvironmentFlags;

Loading…
Cancel
Save