diff --git a/src/main.rs b/src/main.rs index 3b78d43..e0c0fda 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use std::{fs::{File, create_dir_all}, io::{Read, Write}, path::PathBuf}; +use std::{fs::{File, create_dir_all}, io::{Read, Write}, path::{Path, PathBuf}}; use hyper_tls::HttpsConnector; use hyper::{Body, Client, body, client::HttpConnector}; @@ -32,6 +32,7 @@ fn write_to_file(d: &str, p: &str) { } fn read_from_file(p: &str) -> String { + if !Path::new(p).exists() { return "".to_string(); } let mut d = String::new(); let mut ifile = File::open(p).expect("Cannot open file."); ifile.read_to_string(&mut d).expect("Cannot read file.");