From cc8048ea24fa4034f0e22cb5a78b45ce06bedd13 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 24 Jun 2016 17:39:58 +0200 Subject: [PATCH] Impl Ref::update_ref() --- libimagref/src/reference.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libimagref/src/reference.rs b/libimagref/src/reference.rs index 546b1dec..1d807b61 100644 --- a/libimagref/src/reference.rs +++ b/libimagref/src/reference.rs @@ -297,7 +297,24 @@ impl<'a> Ref<'a> { /// Update the Ref by re-checking the file from FS /// This errors if the file is not present or cannot be read() pub fn update_ref(&mut self) -> Result<()> { - unimplemented!() + let current_hash = try!(self.get_current_hash()); + let current_perm = try!(self.get_current_permissions()); + + try!(self.0 + .get_header_mut() + .set("ref.permissions.ro", Value::Boolean(current_perm.readonly())) + .map_err(Box::new) + .map_err(|e| REK::StoreWriteError.into_error_with_cause(e)) + ); + + try!(self.0 + .get_header_mut() + .set("ref.content_hash", Value::String(current_hash)) + .map_err(Box::new) + .map_err(|e| REK::StoreWriteError.into_error_with_cause(e)) + ); + + Ok(()) } /// Get the path of the file which is reffered to by this Ref