Add function to delete a reference header entry
This commit is contained in:
parent
fd6a7f877a
commit
1153fb180b
1 changed files with 12 additions and 1 deletions
|
@ -28,8 +28,9 @@ use libimagentryutil::isa::IsKindHeaderPathProvider;
|
|||
use libimagstore::store::Entry;
|
||||
|
||||
use toml_query::read::TomlValueReadExt;
|
||||
use refstore::UniqueRefPathGenerator;
|
||||
use toml_query::delete::TomlValueDeleteExt;
|
||||
|
||||
use refstore::UniqueRefPathGenerator;
|
||||
use error::Result;
|
||||
use error::RefError as RE;
|
||||
use error::RefErrorKind as REK;
|
||||
|
@ -52,6 +53,8 @@ pub trait Ref {
|
|||
/// Check whether the referenced file still matches its hash
|
||||
fn hash_valid<RPG: UniqueRefPathGenerator>(&self) -> RResult<bool, RPG::Error>;
|
||||
|
||||
fn remove_ref(&mut self) -> Result<()>;
|
||||
|
||||
/// Alias for `r.fs_link_exists() && r.deref().is_file()`
|
||||
fn is_ref_to_file(&self) -> Result<bool> {
|
||||
self.get_path().map(|p| p.is_file())
|
||||
|
@ -104,5 +107,13 @@ impl Ref for Entry {
|
|||
.and_then(|h| Ok(h == self.get_hash()?))
|
||||
}
|
||||
|
||||
fn remove_ref(&mut self) -> Result<()> {
|
||||
let hdr = self.get_header_mut();
|
||||
let _ = hdr.delete("ref.hash")?;
|
||||
let _ = hdr.delete("ref.path")?;
|
||||
let _ = hdr.delete("ref")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue