Ensure that StoreId::storified() does not alter already storified StoreId objects

This commit is contained in:
Matthias Beyer 2016-07-04 12:49:12 +02:00
parent a706680fd5
commit 9605d6daa6

View file

@ -19,11 +19,16 @@ pub struct StoreId(PathBuf);
impl StoreId { impl StoreId {
pub fn storified(self, store: &Store) -> StoreId { pub fn storified(self, store: &Store) -> StoreId {
debug!("Create new store id out of: {:?} and {:?}", store.path(), self); if self.starts_with(store.path()) {
let mut new_id = store.path().clone(); debug!("Not storifying {:?}, because it is already.", self);
new_id.push(self); self
debug!("Created: '{:?}'", new_id); } else {
StoreId::from(new_id) debug!("Create new store id out of: {:?} and {:?}", store.path(), self);
let mut new_id = store.path().clone();
new_id.push(self);
debug!("Created: '{:?}'", new_id);
StoreId::from(new_id)
}
} }
} }