util: Verify that path contains version, else panic!()
This commit is contained in:
parent
6a0baf7bc5
commit
8c6fc7ef41
1 changed files with 19 additions and 1 deletions
|
@ -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('/') {
|
||||
|
|
Loading…
Reference in a new issue