Fix resh importer crashing on end of file (#92)
This commit is contained in:
parent
623df9064e
commit
af707ac5a4
1 changed files with 4 additions and 0 deletions
|
@ -112,8 +112,12 @@ impl Iterator for Resh {
|
||||||
Err(e) => return Some(Err(eyre!("failed to read line: {}", e))), // we can skip past things like invalid utf8
|
Err(e) => return Some(Err(eyre!("failed to read line: {}", e))), // we can skip past things like invalid utf8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// .resh_history.json lies about being a json. It is actually a file containing valid json
|
||||||
|
// on every line. This means that the last line will throw an error, as it is just an EOF.
|
||||||
|
// Without the special case here, that will crash the importer.
|
||||||
let entry = match serde_json::from_str::<ReshEntry>(&self.strbuf) {
|
let entry = match serde_json::from_str::<ReshEntry>(&self.strbuf) {
|
||||||
Ok(e) => e,
|
Ok(e) => e,
|
||||||
|
Err(e) if e.is_eof() => return None,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
return Some(Err(eyre!(
|
return Some(Err(eyre!(
|
||||||
"Invalid entry found in resh_history file: {}",
|
"Invalid entry found in resh_history file: {}",
|
||||||
|
|
Loading…
Reference in a new issue