Do not check whether old or new id exists/does not exist

This commit is contained in:
Matthias Beyer 2016-09-30 12:50:59 +02:00
parent 4f83b22b98
commit f16c09a981

View file

@ -650,7 +650,6 @@ impl Store {
/// Move an entry without loading /// Move an entry without loading
pub fn move_by_id(&self, old_id: StoreId, new_id: StoreId) -> Result<()> { pub fn move_by_id(&self, old_id: StoreId, new_id: StoreId) -> Result<()> {
let new_id = new_id.with_base(self.path().clone()); let new_id = new_id.with_base(self.path().clone());
let old_id = old_id.with_base(self.path().clone()); let old_id = old_id.with_base(self.path().clone());
@ -671,11 +670,9 @@ impl Store {
return Err(SEK::EntryAlreadyExists.into_error()); return Err(SEK::EntryAlreadyExists.into_error());
} }
if !hsmap.contains_key(&old_id) {
return Err(SE::new(SEK::EntryAlreadyBorrowed, None));
} else {
let old_id_pb = try!(old_id.clone().with_base(self.path().clone()).into_pathbuf()); let old_id_pb = try!(old_id.clone().with_base(self.path().clone()).into_pathbuf());
let new_id_pb = try!(new_id.clone().with_base(self.path().clone()).into_pathbuf()); let new_id_pb = try!(new_id.clone().with_base(self.path().clone()).into_pathbuf());
match FileAbstraction::rename(&old_id_pb, &new_id_pb) { match FileAbstraction::rename(&old_id_pb, &new_id_pb) {
Err(e) => return Err(SEK::EntryRenameError.into_error_with_cause(Box::new(e))), Err(e) => return Err(SEK::EntryRenameError.into_error_with_cause(Box::new(e))),
Ok(_) => { Ok(_) => {
@ -688,7 +685,6 @@ impl Store {
.and_then(|entry| hsmap.insert(new_id.clone(), entry)).is_none()) .and_then(|entry| hsmap.insert(new_id.clone(), entry)).is_none())
} }
} }
}
} }