From 6a1ffe059b418ed8838c193e01d83ebaafcacb63 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 5 Sep 2016 14:13:16 +0200 Subject: [PATCH] This patch puts the hasher name in the header This was a bug, as the previous implementation simply sets the hash, but we need to set the hash in a place where we can re-find it with a hasher. --- libimagref/src/reference.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libimagref/src/reference.rs b/libimagref/src/reference.rs index fabb26a5..ba01f341 100644 --- a/libimagref/src/reference.rs +++ b/libimagref/src/reference.rs @@ -168,13 +168,17 @@ impl<'a> Ref<'a> { }; for tpl in [ - Some(("ref", Value::Table(BTreeMap::new()))), - Some(("ref.permissions", Value::Table(BTreeMap::new()))), + Some((String::from("ref"), Value::Table(BTreeMap::new()))), + Some((String::from("ref.permissions"), Value::Table(BTreeMap::new()))), + Some((String::from("ref.path"), Value::String(canonical_path))), + Some((String::from("ref.content_hash"), Value::Table(BTreeMap::new()))), - Some(("ref.path", Value::String(canonical_path))), - - content_hash.map(|h| ("ref.content_hash", Value::String(h))), - permissions.map(|p| ("ref.permissions.ro", Value::Boolean(p.readonly()))), + content_hash.map(|hash| { + (format!("ref.content_hash.{}", h.hash_name()), Value::String(hash)) + }), + permissions.map(|p| { + (String::from("ref.permissions.ro"), Value::Boolean(p.readonly())) + }), ].into_iter() { match tpl {