diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-06-24 17:39:58 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-07-04 19:29:02 +0200 |
commit | cc8048ea24fa4034f0e22cb5a78b45ce06bedd13 (patch) | |
tree | 883dad85503a91d28ad564e463e3bf43836e1607 /libimagref | |
parent | 72a125ab62c633eea81688ad1787fdabc107c7b1 (diff) |
Impl Ref::update_ref()
Diffstat (limited to 'libimagref')
-rw-r--r-- | libimagref/src/reference.rs | 19 |
1 files changed, 18 insertions, 1 deletions
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 |