mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-28 11:47:01 +02:00
Don't prompt user for keychain password more than once
This commit is contained in:
@@ -158,15 +158,14 @@ impl EncryptionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_master_key(&self) -> Result<MasterKey> {
|
fn get_master_key(&self) -> Result<MasterKey> {
|
||||||
{
|
// NOTE: This locks the key for the entire function which seems wrong, but this prevents
|
||||||
let master_secret = self.cached_master_key.lock().unwrap();
|
// concurrent access from prompting the user for a keychain password multiple times.
|
||||||
if let Some(k) = master_secret.as_ref() {
|
let mut master_secret = self.cached_master_key.lock().unwrap();
|
||||||
return Ok(k.to_owned());
|
if let Some(k) = master_secret.as_ref() {
|
||||||
}
|
return Ok(k.to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mkey = MasterKey::get_or_create(&self.app_id, KEY_USER)?;
|
let mkey = MasterKey::get_or_create(&self.app_id, KEY_USER)?;
|
||||||
let mut master_secret = self.cached_master_key.lock().unwrap();
|
|
||||||
*master_secret = Some(mkey.clone());
|
*master_secret = Some(mkey.clone());
|
||||||
Ok(mkey)
|
Ok(mkey)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user