Fix Store::delete() for nonexistent IDs

If the ID does not exist, we should return an error instead of doing
nothing, shouldn't we?
This commit is contained in:
Matthias Beyer 2016-09-19 11:07:38 +02:00
parent 8345ff8248
commit fd41fe5998

View file

@ -573,9 +573,13 @@ impl Store {
};
// if the entry is currently modified by the user, we cannot drop it
if entries.get(&id).map(|e| e.is_borrowed()).unwrap_or(false) {
return Err(SE::new(SEK::IdLocked, None))
.map_err_into(SEK::DeleteCallError);
match entries.get(&id) {
None => {
return Err(SEK::FileNotFound.into_error()).map_err_into(SEK::DeleteCallError)
},
Some(e) => if e.is_borrowed() {
return Err(SE::new(SEK::IdLocked, None)).map_err_into(SEK::DeleteCallError)
}
}
// remove the entry first, then the file