diff --git a/datman/src/commands/prune.rs b/datman/src/commands/prune.rs index 7280a45..de5a40b 100644 --- a/datman/src/commands/prune.rs +++ b/datman/src/commands/prune.rs @@ -132,7 +132,12 @@ pub fn prune_with_retention_policy( } for to_remove in pointers_to_remove { - remove_pointer_safely(&pile, &to_remove)?; + let res = remove_pointer_safely(&pile, &to_remove).context("removing prunable pointers"); + + pile.flush() + .context("flushing pile after removing pointers")?; + + res?; } Ok(()) diff --git a/yama/src/operations.rs b/yama/src/operations.rs index bcea48b..ed3dfbb 100644 --- a/yama/src/operations.rs +++ b/yama/src/operations.rs @@ -1,7 +1,7 @@ use crate::commands::{fully_integrate_pointer_node, retrieve_tree_node, store_tree_node}; use crate::pile::{Pile, RawPile}; use crate::tree::{differentiate_node_in_place, integrate_node_in_place}; -use anyhow::anyhow; +use anyhow::{anyhow, Context}; use log::info; pub mod checking; @@ -15,10 +15,12 @@ pub fn remove_pointer_safely(pile: &Pile

, name: &str) -> anyhow:: let mut this_pointer = pile .read_pointer(name)? .ok_or_else(|| anyhow!("Pointer {:?} does not exist so can not be deleted.", name))?; - let mut this_node = retrieve_tree_node(&pile, this_pointer.chunk_ref.clone())?; + let mut this_node = retrieve_tree_node(&pile, this_pointer.chunk_ref.clone()) + .context("retrieving 'this' node")?; let new_parent_name = this_pointer.parent_pointer.clone(); - fully_integrate_pointer_node(pile, &mut this_node.node, &mut this_pointer)?; + fully_integrate_pointer_node(pile, &mut this_node.node, &mut this_pointer) + .context("integrating new parent")?; let new_parent = if let Some(ref new_parent_name) = new_parent_name { let mut new_parent_pointer = pile @@ -62,6 +64,10 @@ pub fn remove_pointer_safely(pile: &Pile

, name: &str) -> anyhow:: pointer_data.chunk_ref = new_chunk_ref; // write the pointer back. pile.write_pointer(pointer.as_str(), &pointer_data)?; + + // we must flush chunks before deleting the pointer + pile.flush() + .context("flushing after writing pointer back")?; } } }