From d6c5913c3ea1c71966119f2bbf01f69b2c301a8f Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 18 May 2020 03:13:45 -0700 Subject: canonicalize --- src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 73e8b33..f161007 100644 --- a/src/main.rs +++ b/src/main.rs @@ -456,16 +456,24 @@ fn restore(save_path: &str) -> Option<(String, usize, usize)> { ) }; + let canon = |s: String| { + std::fs::canonicalize(s) + .unwrap() + .to_str() + .unwrap() + .to_string() + }; + match (save, path) { (Err(_), None) => None, - (Err(_), Some(path)) => Some((path, 0, 0)), + (Err(_), Some(path)) => Some((canon(path), 0, 0)), (Ok(save), None) => Some(get_save(save)), (Ok(save), Some(path)) => { let save = get_save(save); if path == save.0 { Some(save) } else { - Some((path, 0, 0)) + Some((canon(path), 0, 0)) } } } -- cgit v1.2.3