1
0
forked from brl/citadel-tools

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 { } else if ver_b > ver_a {
Ok(b) Ok(b)
} else { } else {
// versions are the same so compare file times // versions are the same so compare build timestamps
let a_time = a.path().metadata()?.created()?; let ts_a = parse_timestamp(&a)?;
let b_time = b.path().metadata()?.created()?; let ts_b = parse_timestamp(&b)?;
if a_time > b_time { if ts_a > ts_b {
Ok(a) Ok(a)
} else { } else {
Ok(b) 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 { fn current_kernel_version() -> String {
let utsname = util::uname(); let utsname = util::uname();
let v = utsname.release().split("-").collect::<Vec<_>>(); let v = utsname.release().split("-").collect::<Vec<_>>();