Separate out the pointer operations

This commit is contained in:
Olivier 'reivilibre' 2022-05-28 23:13:44 +01:00
parent 23b352f936
commit 081a1922c7
1 changed files with 25 additions and 7 deletions

View File

@ -240,7 +240,6 @@ pub fn store_fully<PT: ProgressTracker>(
parent: Option<String>,
num_workers: u8,
progress_bar: &mut PT,
use_pipelined_storage: bool,
) -> anyhow::Result<()> {
if let Some(parent) = parent.as_ref() {
let mut parent_pointer = pile.read_pointer(parent)?.ok_or_else(|| {
@ -254,7 +253,30 @@ pub fn store_fully<PT: ProgressTracker>(
fully_integrate_pointer_node(&pile, &mut parent_node.node, &mut parent_pointer)?;
differentiate_node_in_place(&mut root_node, &parent_node.node)?;
}
let pointer_data = store_without_pointer_ops(
&pile,
&root_dir,
root_node,
parent,
num_workers,
progress_bar,
)?;
// TODO(newver) Allow the pointer to be returned separately.
pile.write_pointer(&new_pointer_name, &pointer_data)?;
pile.flush()?;
Ok(())
}
fn store_without_pointer_ops<PT: ProgressTracker>(
pile: &Arc<Pile<Box<dyn RawPile>>>,
root_dir: &PathBuf,
mut root_node: TreeNode,
parent: Option<String>,
num_workers: u8,
progress_bar: &mut PT,
) -> anyhow::Result<PointerData> {
// TODO make these configurable
let sps = StoragePipelineSettings {
num_compressors: get_number_of_workers("YAMA_PL_COMPRESSORS") as u32,
@ -301,9 +323,5 @@ pub fn store_fully<PT: ProgressTracker>(
uid_lookup,
gid_lookup,
};
// TODO(newver) Allow the pointer to be returned separately.
pile.write_pointer(&new_pointer_name, &pointer_data)?;
pile.flush()?;
Ok(())
Ok(pointer_data)
}