summaryrefslogtreecommitdiffstats
path: root/libimagstore
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-09-08 15:16:07 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-10-15 15:49:00 +0200
commitc0eb329abf37007659f15bc655d1a65aab421241 (patch)
tree81aa03105f951098a24e96730f7129c21c5199bb /libimagstore
parent2363d6ba306318e6d96a307aaf0a89e66cf733c8 (diff)
Simplify hashmap fetching and error construction
Diffstat (limited to 'libimagstore')
-rw-r--r--libimagstore/src/store.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs
index e21bb2ce..321e4496 100644
--- a/libimagstore/src/store.rs
+++ b/libimagstore/src/store.rs
@@ -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();