fn compress_paths(
    archive_paths: &[(PackType, path::PathBuf)],
) -> Result<Vec<(PackType, path::PathBuf)>> {
    let pb = default_progress_bar(archive_paths.len() as u64 - 1);
    pb.set_prefix(&format!(
        "{:width$}",
        "Compressing archives",
        width = PROGRESS_PREFIX_LEN
    ));
    let res = archive_paths
        .into_par_iter()
        .map(|(pack_type, path)| {
            let input_file = File::open(&path).with_context(|| {
                format!("Failed to open archive '{}'.", &path.to_string_lossy())
            })?;
            let mut reader = BufReader::new(input_file);
            let mut output_path = path::PathBuf::from(path);
            output_path.set_extension("tar.xz");
            let output_file: File = File::create(&output_path).with_context(|| {
                format!(
                    "Failed opening compressed archive '{}' for writing.",
                    &output_path.to_string_lossy()
                )
            })?;
            let writer = BufWriter::new(output_file);
            let mut encoder = xz2::write::XzEncoder::new(writer, 9);
            std::io::copy(&mut reader, &mut encoder)?;
            pb.inc(1);
            Ok((*pack_type, output_path))
        })
        .collect::<Result<Vec<(PackType, path::PathBuf)>>>()?;
    pb.finish();

    Ok(res)
}
/// Takes a list of archive paths, compresses them with LZMA and returns
/// the updated paths.
/// TODO: Remove compressed artifacts.
Takes a list of archive paths, compresses them with LZMA and returns
the updated paths.
TODO: Remove compressed artifacts.
Takes a list of archive paths compresses them with LZMA and returns the updated paths . TODO : Remove compressed artifacts .
fn compress_paths(
    archive_paths: &[(PackType, path::PathBuf)],
) -> Result<Vec<(PackType, path::PathBuf)>> {
    let pb = default_progress_bar(archive_paths.len() as u64 - 1);
    pb.set_prefix(&format!(
        "{:width$}",
        "Compressing archives",
        width = PROGRESS_PREFIX_LEN
    ));
    let res = archive_paths
        .into_par_iter()
        .map(|(pack_type, path)| {
            let input_file = File::open(&path).with_context(|| {
                format!("Failed to open archive '{}'.", &path.to_string_lossy())
            })?;
            let mut reader = BufReader::new(input_file);
            let mut output_path = path::PathBuf::from(path);
            output_path.set_extension("tar.xz");
            let output_file: File = File::create(&output_path).with_context(|| {
                format!(
                    "Failed opening compressed archive '{}' for writing.",
                    &output_path.to_string_lossy()
                )
            })?;
            let writer = BufWriter::new(output_file);
            let mut encoder = xz2::write::XzEncoder::new(writer, 9);
            std::io::copy(&mut reader, &mut encoder)?;
            pb.inc(1);
            Ok((*pack_type, output_path))
        })
        .collect::<Result<Vec<(PackType, path::PathBuf)>>>()?;
    pb.finish();
    Ok(res)
}
fn compress_paths ( archive_paths : & [ ( PackType , path :: PathBuf ) ] , ) -> Result < Vec < ( PackType , path :: PathBuf ) > > { let pb = default_progress_bar ( archive_paths . len ( ) as u64 - 1 ) ; pb . set_prefix ( & format ! ( " " " " width PROGRESS_PREFIX_LEN ) ) ; let res = archive_paths . into_par_iter ( ) . map ( | ( pack_type , path ) | { let input_file = File :: open ( & path ) . with_context ( | | { format ! ( " " path to_string_lossy ( ) ) } ) ? ; let mut reader = BufReader :: new ( input_file ) ; let mut output_path = path :: PathBuf :: from ( path ) ; output_path . set_extension ( " " ) ; let output_file : File = File :: create ( & output_path ) . with_context ( | | { format ! ( " " output_path to_string_lossy ( ) ) } ) ? ; let writer = BufWriter :: new ( output_file ) ; let mut encoder = xz2 :: write :: XzEncoder :: new ( writer , 9 ) ; std :: io :: copy ( & mut reader , & mut encoder ) ? ; pb . inc ( 1 ) ; Ok ( ( * pack_type , output_path ) ) } ) . collect :: < Result < Vec < ( PackType , path :: PathBuf ) > > > ( ) ? ; pb . finish ( ) ; Ok ( res ) }
Takes a list of archive paths, compresses them with LZMA and returns
the updated paths.
Takes a list of archive paths compresses them with LZMA and returns the updated paths .
archive_paths
&[(PackType, path::PathBuf)]
archive_paths
&[(PackType, path::PathBuf)]