diff --git a/imag-store/src/util.rs b/imag-store/src/util.rs index d339dc6f..6ebb3a2d 100644 --- a/imag-store/src/util.rs +++ b/imag-store/src/util.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; use std::str::Split; use clap::ArgMatches; +use semver::Version; use toml::Value; use libimagstore::store::EntryHeader; @@ -10,7 +11,24 @@ use libimagrt::runtime::Runtime; use libimagutil::key_value_split::IntoKeyValue; pub fn build_entry_path(rt: &Runtime, path_elem: &str) -> PathBuf { - debug!("Building path..."); + debug!("Checking path element for version"); + { + let contains_version = { + path_elem.split("~") + .last() + .map(|version| Version::parse(version).is_ok()) + .unwrap_or(false) + }; + + if !contains_version { + debug!("Version cannot be parsed inside {:?}", path_elem); + warn!("Path does not contain version. Will panic now!"); + panic!("No version in path"); + } + } + debug!("Version checking succeeded"); + + debug!("Building path from {:?}", path_elem); let mut path = rt.store().path().clone(); if path_elem.chars().next() == Some('/') {