Don't ask for master password in clean command

This commit is contained in:
TheAwiteb 2023-12-24 20:26:51 +03:00
parent bdfb17d888
commit 4b15b9403a
No known key found for this signature in database
GPG key ID: ABF818BD15DC2D34

View file

@ -63,6 +63,12 @@ impl Cli {
"Getting password file: {}", "Getting password file: {}",
passwords_file.to_string_lossy() passwords_file.to_string_lossy()
); );
let password_manager = if matches!(self.command, Commands::Clean(..)) {
Passwords {
passwords_file,
..Default::default()
}
} else {
let password = scanpw::scanpw!("Master Password: "); let password = scanpw::scanpw!("Master Password: ");
if password::is_new_password_file(&passwords_file)? { if password::is_new_password_file(&passwords_file)? {
@ -79,10 +85,11 @@ impl Cli {
} }
let master_password = sha256::digest(password); let master_password = sha256::digest(password);
let password_manager = Passwords::try_reload( Passwords::try_reload(
passwords_file, passwords_file,
master_password.into_bytes().into_iter().take(32).collect(), master_password.into_bytes().into_iter().take(32).collect(),
)?; )?
};
self.command.run(password_manager)?; self.command.run(password_manager)?;
Ok(()) Ok(())