From bda6410d7b962758ee6449c5778b6a1b08fd6dbf Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Mon, 7 Jan 2019 19:00:02 -0500 Subject: [PATCH] Use new timestamp metainfo field to compare images with same version. --- libcitadel/src/resource.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libcitadel/src/resource.rs b/libcitadel/src/resource.rs index b0c9d24..834eda1 100644 --- a/libcitadel/src/resource.rs +++ b/libcitadel/src/resource.rs @@ -414,10 +414,10 @@ fn compare_images(a: Option, b: ResourceImage) -> Result 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, b: ResourceImage) -> Result Result { + let ts = img.metainfo() + .timestamp() + .parse::() + .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::>();