Make StoreId.base optional

This commit is contained in:
Matthias Beyer 2016-08-07 16:53:33 +02:00
parent ad92b05fb4
commit 8dff5685fd

View file

@ -15,7 +15,7 @@ use store::Store;
/// The Index into the Store /// The Index into the Store
#[derive(Debug, Clone, PartialEq, Hash, Eq, PartialOrd, Ord)] #[derive(Debug, Clone, PartialEq, Hash, Eq, PartialOrd, Ord)]
pub struct StoreId { pub struct StoreId {
store_location: PathBuf, base: Option<PathBuf>,
id: PathBuf, id: PathBuf,
} }
@ -28,7 +28,7 @@ impl StoreId {
} else { } else {
debug!("Create new store id out of: {:?} and {:?}", store.path(), self.id); debug!("Create new store id out of: {:?} and {:?}", store.path(), self.id);
let new_id = StoreId { store_location: store.path().clone(), self.id }; let new_id = StoreId { base: Some(store.path().clone()), self.id };
debug!("Created: '{:?}'", new_id); debug!("Created: '{:?}'", new_id);
new_id new_id
@ -53,7 +53,7 @@ impl StoreId {
impl Into<PathBuf> for StoreId { impl Into<PathBuf> for StoreId {
fn into(self) -> PathBuf { fn into(self) -> PathBuf {
let mut base = self.store_location; let mut base = self.base.unwrap_or(PathBuf::from("/"));
base.push(self.id); base.push(self.id);
base base
} }