Key load avoid warning (#1303)

* avoid warning with key

* fix intendations

* more intendation fix

* ok() instead of expect()
This commit is contained in:
Nikolay Volf 2016-06-16 16:14:22 +04:00 committed by arkpar
parent 1baa150086
commit b4aae6bd9c
2 changed files with 15 additions and 8 deletions

View File

@ -627,7 +627,10 @@ impl KeyDirectory {
}
}
/// Checks if key exists
pub fn exists(&self, id: &Uuid) -> bool {
KeyDirectory::load_key(&self.key_path(id)).is_ok()
}
}

View File

@ -348,6 +348,10 @@ impl SecretStore {
garbage_lock.shrink_to_fit();
}
fn exists(&self, key: &H128) -> bool {
self.directory.exists(key)
}
}
fn derive_key_iterations(password: &str, salt: &H256, c: u32) -> (Bytes, Bytes) {
@ -408,7 +412,7 @@ impl EncryptedHashMap<H128> for SecretStore {
}
fn insert<Value: FromRawBytesVariable + BytesConvertable>(&mut self, key: H128, value: Value, password: &str) -> Option<Value> {
let previous = if let Ok(previous_value) = self.get(&key, password) { Some(previous_value) } else { None };
let previous = if !self.exists(&key) { None } else { self.get(&key, password).ok() };
// crypto random initiators
let salt = H256::random();