[feat] check auth path
This commit is contained in:
@@ -102,14 +102,23 @@ fn check_auth(fpath: String, auth: String) -> bool{
|
||||
|
||||
|
||||
|
||||
// read file
|
||||
let got_auth = std::fs::read_to_string(&path).expect("Something went wrong reading the file");
|
||||
// read file, return false when error
|
||||
let got_auth = std::fs::read_to_string(&path);
|
||||
|
||||
// check auth
|
||||
if got_auth != auth {
|
||||
// check read error
|
||||
if got_auth.is_err() {
|
||||
println!("Error reading file {}", path.display());
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
// check auth
|
||||
if got_auth.unwrap() != auth {
|
||||
println!("Auth does not match");
|
||||
return false;
|
||||
}
|
||||
println!("Auth matches");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user