From d28913b141bcbcaf82d4ed5caff27dcade6647c7 Mon Sep 17 00:00:00 2001 From: Mystikfluu Date: Sat, 1 Apr 2023 17:00:22 +0200 Subject: [PATCH] check if token file exists prevents crash if token file is missing note: this is a quick fix; returned token should be Option instead of String --- src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 44df0b2..ba16c37 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,6 +29,10 @@ struct Saved { fn get_token() -> String { let mut token: String = String::new(); + //check if file exists + if !std::path::Path::new(&(get_ipass_folder()+"token.ipasst")).exists() { + return "".to_string(); + } File::open(get_ipass_folder()+"token.ipasst").unwrap().read_to_string(&mut token).unwrap(); token }