Simplify hashmap fetching and error construction

This commit is contained in:
Matthias Beyer 2016-09-08 15:16:07 +02:00
parent 2363d6ba30
commit c0eb329abf
1 changed files with 9 additions and 6 deletions

View File

@ -636,12 +636,15 @@ impl Store {
-> Result<()>
{
let new_id = new_id.with_base(self.path().clone());
let hsmap = self.entries.write();
if hsmap.is_err() {
return Err(SE::new(SEK::LockPoisoned, None)).map_err_into(SEK::MoveCallError)
}
if hsmap.unwrap().contains_key(&new_id) {
return Err(SE::new(SEK::EntryAlreadyExists, None)).map_err_into(SEK::MoveCallError)
let hsmap = try!(
self.entries
.write()
.map_err(|_| SEK::LockPoisoned.into_error())
.map_err_into(SEK::MoveCallError)
);
if hsmap.contains_key(&new_id) {
return Err(SEK::EntryAlreadyExists.into_error()).map_err_into(SEK::MoveCallError)
}
let old_id = entry.get_location().clone();