Skip to content

Commit e4989eb

Browse files
authored
fix: properly ignore current run on rage -i (#6)
1 parent bb80fef commit e4989eb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/persistent_data.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ impl PersistentDataStore {
170170
.collect::<Result<Vec<_>, std::io::Error>>()?;
171171

172172
run_dirs.sort_unstable();
173+
run_dirs.pop(); // Don't include the current run.
173174
run_dirs.reverse();
175+
176+
debug!("Found past runs: {:?}", run_dirs);
174177
Ok(run_dirs)
175178
}
176179

@@ -180,8 +183,11 @@ impl PersistentDataStore {
180183
let dir = run_dirs.get(invocation);
181184
match dir {
182185
Some(dir) => {
186+
debug!("Reading run info from {}", dir.display());
187+
let run_info = std::fs::read_to_string(dir.join("run_info.json"))
188+
.context("couldn't read run info json")?;
183189
let run_info: RunInfo =
184-
serde_json::from_str(&std::fs::read_to_string(dir.join("run_info.json"))?)?;
190+
serde_json::from_str(&run_info).context("couldn't deserialize run info")?;
185191
Ok(run_info)
186192
}
187193
None => {
@@ -199,7 +205,7 @@ impl PersistentDataStore {
199205
let mut ret = Vec::new();
200206

201207
// Skip the first one as it is the current run.
202-
for dir in run_dirs.into_iter().skip(1) {
208+
for dir in run_dirs.into_iter() {
203209
debug!("Reading run info from {}", dir.display());
204210

205211
let run_info: RunInfo =

0 commit comments

Comments
 (0)