diff options
author | Jamie Quigley <jamie@quigley.xyz> | 2021-05-09 20:09:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-09 19:09:09 +0000 |
commit | af707ac5a4fba2147f10b6c663d66ace1c54cda0 (patch) | |
tree | 257b9a7389f992fbb2b89ef519ab1a64b8803935 /atuin-client/src/import | |
parent | 623df9064e76a1090bdae39617896bb767b34543 (diff) |
Fix resh importer crashing on end of file (#92)
Diffstat (limited to 'atuin-client/src/import')
-rw-r--r-- | atuin-client/src/import/resh.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/atuin-client/src/import/resh.rs b/atuin-client/src/import/resh.rs index a0378c36f..efe5bb5c3 100644 --- a/atuin-client/src/import/resh.rs +++ b/atuin-client/src/import/resh.rs @@ -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 } + // .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) { Ok(e) => e, + Err(e) if e.is_eof() => return None, Err(e) => { return Some(Err(eyre!( "Invalid entry found in resh_history file: {}", |