From fd41fe59987fd7801d7c1bd4d9f05d7a35573617 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 19 Sep 2016 11:07:38 +0200 Subject: [PATCH] Fix Store::delete() for nonexistent IDs If the ID does not exist, we should return an error instead of doing nothing, shouldn't we? --- libimagstore/src/store.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 284c9228..e1cd85b7 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -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