Rename new to new_from_pile.

This commit is contained in:
Olivier 'reivilibre' 2021-11-20 10:58:49 +00:00
parent 4fa300e575
commit ff52dd74e7
4 changed files with 6 additions and 5 deletions

View File

@ -231,7 +231,8 @@ pub fn backup_source_to_destination<PT: ProgressTracker>(
}
info!("Will write as pointer {:?}.", pointer_name);
let mut chunker = yama::chunking::RecursiveChunker::new(SENSIBLE_THRESHOLD, &pile);
let mut chunker =
yama::chunking::RecursiveChunker::new_from_pile(SENSIBLE_THRESHOLD, &pile);
let mut process = open_stdout_backup_process(extra_args, helper)?;

View File

@ -53,7 +53,7 @@ pub struct RecursiveChunker<'pile, RP: RawPile> {
}
impl<'pile, RP: RawPile> RecursiveChunker<'pile, RP> {
pub fn new(threshold: usize, pile: &'pile Pile<RP>) -> Self {
pub fn new_from_pile(threshold: usize, pile: &'pile Pile<RP>) -> Self {
RecursiveChunker {
pile,
buffer: vec![],
@ -112,7 +112,7 @@ impl<'pile, RP: RawPile> RecursiveChunker<'pile, RP> {
if self.buffer.len() > self.threshold {
if self.next_layer.is_none() {
// start chunking
self.next_layer = Some(Box::new(RecursiveChunker::new(
self.next_layer = Some(Box::new(RecursiveChunker::new_from_pile(
self.threshold,
self.pile.clone(),
)));

View File

@ -112,7 +112,7 @@ pub fn store_tree_node<RP: RawPile>(
root_tree_node: &RootTreeNode,
) -> anyhow::Result<RecursiveChunkRef> {
let serialised = serde_bare::to_vec(root_tree_node)?;
let mut chunker = RecursiveChunker::new(SENSIBLE_THRESHOLD, pile);
let mut chunker = RecursiveChunker::new_from_pile(SENSIBLE_THRESHOLD, pile);
io::copy(&mut (&serialised[..]), &mut chunker)?;
let chunk_ref = chunker.finish()?;
Ok(chunk_ref)

View File

@ -93,7 +93,7 @@ pub fn store_worker<RP: RawPile>(
let full_path = root.join(&path);
match File::open(&full_path) {
Ok(mut file) => {
let mut chunker = RecursiveChunker::new(SENSIBLE_THRESHOLD, &pile);
let mut chunker = RecursiveChunker::new_from_pile(SENSIBLE_THRESHOLD, &pile);
// streaming copy from file to chunker, really cool :)
io::copy(&mut file, &mut chunker)?;
let chunk_ref = chunker.finish()?;