From d1f07cd087b712f50bf7a250fd0daf67459858ce Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 25 Aug 2016 14:27:42 +0200 Subject: [PATCH] Add check in StoreId::new() whether the local part is absolute --- libimagstore/src/storeid.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libimagstore/src/storeid.rs b/libimagstore/src/storeid.rs index 1faf0375..94eb0c4a 100644 --- a/libimagstore/src/storeid.rs +++ b/libimagstore/src/storeid.rs @@ -20,8 +20,15 @@ pub struct StoreId { impl StoreId { - pub fn new(base: Option, id: PathBuf) -> StoreId { - StoreId { base: base, id: id } + pub fn new(base: Option, id: PathBuf) -> Result { + if id.is_absolute() { + Err(SEK::StoreIdLocalPartAbsoluteError.into_error()) + } else { + Ok(StoreId { + base: base, + id: id + }) + } } pub fn storified(self, store: &Store) -> StoreId {