break chunks into lines before adding them

master
rascul 2 years ago
parent 6e03d29f85
commit 1d6ddaa6c4

@ -52,7 +52,7 @@ pub fn parse_log(raw: &Vec<u8>) -> Result<Value> {
return Err("chunk size too small".into()); return Err("chunk size too small".into());
} }
let (delta, size) = { let (mut delta, size) = {
if let Ok((delta, size)) = chunk32(&chunk) { if let Ok((delta, size)) = chunk32(&chunk) {
(delta, size) (delta, size)
} else { } else {
@ -79,10 +79,13 @@ pub fn parse_log(raw: &Vec<u8>) -> Result<Value> {
let text: String = String::from_utf8_lossy(&text_chunk).into(); let text: String = String::from_utf8_lossy(&text_chunk).into();
let text: String = convert_escaped(&text)?; let text: String = convert_escaped(&text)?;
let mut bm: Map<String, Value> = Map::new(); for line in text.lines() {
bm.insert("delta".into(), delta.into()); let mut map: Map<String, Value> = Map::new();
bm.insert("text".into(), text.into()); map.insert("delta".into(), delta.into());
chunks.push(bm); map.insert("text".into(), line.trim().into());
chunks.push(map);
delta = 0;
}
} }
Ok(chunks.into()) Ok(chunks.into())

Loading…
Cancel
Save