Use new timestamp metainfo field to compare images with same version.

This commit is contained in:
Bruce Leidl 2019-01-07 19:00:02 -05:00
parent da0922c29d
commit bda6410d7b

View File

@ -414,10 +414,10 @@ fn compare_images(a: Option<ResourceImage>, b: ResourceImage) -> Result<Resource
} else if ver_b > ver_a {
Ok(b)
} else {
// versions are the same so compare file times
let a_time = a.path().metadata()?.created()?;
let b_time = b.path().metadata()?.created()?;
if a_time > b_time {
// versions are the same so compare build timestamps
let ts_a = parse_timestamp(&a)?;
let ts_b = parse_timestamp(&b)?;
if ts_a > ts_b {
Ok(a)
} else {
Ok(b)
@ -425,6 +425,14 @@ fn compare_images(a: Option<ResourceImage>, b: ResourceImage) -> Result<Resource
}
}
fn parse_timestamp(img: &ResourceImage) -> Result<usize> {
let ts = img.metainfo()
.timestamp()
.parse::<usize>()
.context(format!("Error parsing timestamp for resource image {}", img.path().display()))?;
Ok(ts)
}
fn current_kernel_version() -> String {
let utsname = util::uname();
let v = utsname.release().split("-").collect::<Vec<_>>();