fn assemble_chunks(
    chunks: Vec<(&FileChunk, &[u8])>,
    output_folder: &str,
) -> Result<(), Box<dyn Error>> {
    // Get path for chunks
    let path = chunks[0].0.local_path.clone();
    // Create file
    let mut cfile = create_file(&path, output_folder)?;
    // Write the file
    for chunk in chunks.iter() {
        cfile.seek(std::io::SeekFrom::Start(chunk.0.offset as u64))?;
        cfile.write_all(chunk.1)?;
    }
    Ok(())
}
// Find all chunks associated with the same path
// and combine them in order according to their offsets and
// lengths and then save to the original local path
Find all chunks associated with the same path
and combine them in order according to their offsets and
lengths and then save to the original local path
Find all chunks associated with the same path and combine them in order according to their offsets and lengths and then save to the original local path
fn assemble_chunks(
    chunks: Vec<(&FileChunk, &[u8])>,
    output_folder: &str,
) -> Result<(), Box<dyn Error>> {
    // Get path for chunks
    let path = chunks[0].0.local_path.clone();
    // Create file
    let mut cfile = create_file(&path, output_folder)?;
    // Write the file
    for chunk in chunks.iter() {
        cfile.seek(std::io::SeekFrom::Start(chunk.0.offset as u64))?;
        cfile.write_all(chunk.1)?;
    }
    Ok(())
}
fn assemble_chunks ( chunks : Vec < ( & FileChunk , & [ u8 ] ) > , output_folder : & str , ) -> Result < ( ) , Box < dyn Error > > { // Get path for chunks let path = chunks [ 0 ] . 0 . local_path . clone ( ) ; // Create file let mut cfile = create_file ( & path , output_folder ) ? ; // Write the file for chunk in chunks . iter ( ) { cfile . seek ( std :: io :: SeekFrom :: Start ( chunk . 0 . offset as u64 ) ) ? ; cfile . write_all ( chunk . 1 ) ? ; } Ok ( ( ) ) }
Find all chunks associated with the same path
and combine them in order according to their offsets and
lengths and then save to the original local path
Find all chunks associated with the same path and combine them in order according to their offsets and lengths and then save to the original local path
chunks
Vec<(&FileChunk, &[u8])>
output_folder
&str
chunks
Vec<(&FileChunk, &[u8])>
output_folder
&str