Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Remove some unwraps from parity/helpers #3364

Merged
merged 2 commits into from
Nov 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions parity/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,18 @@ pub fn execute_upgrades(
/// Prompts user asking for password.
pub fn password_prompt() -> Result<String, String> {
use rpassword::read_password;
const STDIN_ERROR: &'static str = "Unable to ask for password on non-interactive terminal.";

println!("Please note that password is NOT RECOVERABLE.");
print!("Type password: ");
flush_stdout();

let password = read_password().unwrap();
let password = try!(read_password().map_err(|_| STDIN_ERROR.to_owned()));

print!("Repeat password: ");
flush_stdout();

let password_repeat = read_password().unwrap();
let password_repeat = try!(read_password().map_err(|_| STDIN_ERROR.to_owned()));

if password != password_repeat {
return Err("Passwords do not match!".into());
Expand All @@ -314,7 +315,7 @@ pub fn passwords_from_files(files: Vec<String>) -> Result<Vec<String>, String> {
let file = try!(File::open(filename).map_err(|_| format!("{} Unable to read password file. Ensure it exists and permissions are correct.", filename)));
let reader = BufReader::new(&file);
let lines = reader.lines()
.map(|l| l.unwrap())
.filter_map(|l| l.ok())
.collect::<Vec<String>>();
Ok(lines)
}).collect::<Result<Vec<Vec<String>>, String>>();
Expand Down