fn unpack_archive(archive: Box<dyn Archive>, version: &Version) -> Fallible<()> {
    let temp = create_staging_dir()?;
    debug!("Unpacking yarn into '{}'", temp.path().display());

    let progress = progress_bar(
        archive.origin(),
        &tool_version("yarn", version),
        archive
            .uncompressed_size()
            .unwrap_or_else(|| archive.compressed_size()),
    );
    let version_string = version.to_string();

    archive
        .unpack(temp.path(), &mut |_, read| {
            progress.inc(read as u64);
        })
        .with_context(|_| ErrorDetails::UnpackArchiveError {
            tool: "Yarn".into(),
            version: version_string.clone(),
        })?;

    let dest = volta_home()?.yarn_image_dir(&version_string);
    ensure_containing_dir_exists(&dest)
        .with_context(|_| ErrorDetails::ContainingDirError { path: dest.clone() })?;

    rename(
        temp.path().join(Yarn::archive_basename(&version_string)),
        &dest,
    )
    .with_context(|_| ErrorDetails::SetupToolImageError {
        tool: "Yarn".into(),
        version: version_string.clone(),
        dir: dest.clone(),
    })?;

    progress.finish_and_clear();

    // Note: We write this after the progress bar is finished to avoid display bugs with re-renders of the progress
    debug!("Installing yarn in '{}'", dest.display());

    Ok(())
}
/// Unpack the yarn archive into the image directory so that it is ready for use
Unpack the yarn archive into the image directory so that it is ready for use
Unpack the yarn archive into the image directory so that it is ready for use
fn unpack_archive(archive: Box<dyn Archive>, version: &Version) -> Fallible<()> {
    let temp = create_staging_dir()?;
    debug!("Unpacking yarn into '{}'", temp.path().display());
    let progress = progress_bar(
        archive.origin(),
        &tool_version("yarn", version),
        archive
            .uncompressed_size()
            .unwrap_or_else(|| archive.compressed_size()),
    );
    let version_string = version.to_string();
    archive
        .unpack(temp.path(), &mut |_, read| {
            progress.inc(read as u64);
        })
        .with_context(|_| ErrorDetails::UnpackArchiveError {
            tool: "Yarn".into(),
            version: version_string.clone(),
        })?;
    let dest = volta_home()?.yarn_image_dir(&version_string);
    ensure_containing_dir_exists(&dest)
        .with_context(|_| ErrorDetails::ContainingDirError { path: dest.clone() })?;
    rename(
        temp.path().join(Yarn::archive_basename(&version_string)),
        &dest,
    )
    .with_context(|_| ErrorDetails::SetupToolImageError {
        tool: "Yarn".into(),
        version: version_string.clone(),
        dir: dest.clone(),
    })?;
    progress.finish_and_clear();
    // Note: We write this after the progress bar is finished to avoid display bugs with re-renders of the progress
    debug!("Installing yarn in '{}'", dest.display());
    Ok(())
}
fn unpack_archive ( archive : Box < dyn Archive > , version : & Version ) -> Fallible < ( ) > { let temp = create_staging_dir ( ) ? ; debug ! ( " " temp path ( ) display ( ) ) ; let progress = progress_bar ( archive . origin ( ) , & tool_version ( " " , version ) , archive . uncompressed_size ( ) . unwrap_or_else ( | | archive . compressed_size ( ) ) , ) ; let version_string = version . to_string ( ) ; archive . unpack ( temp . path ( ) , & mut | _ , read | { progress . inc ( read as u64 ) ; } ) . with_context ( | _ | ErrorDetails :: UnpackArchiveError { tool : " " . into ( ) , version : version_string . clone ( ) , } ) ? ; let dest = volta_home ( ) ? . yarn_image_dir ( & version_string ) ; ensure_containing_dir_exists ( & dest ) . with_context ( | _ | ErrorDetails :: ContainingDirError { path : dest . clone ( ) } ) ? ; rename ( temp . path ( ) . join ( Yarn :: archive_basename ( & version_string ) ) , & dest , ) . with_context ( | _ | ErrorDetails :: SetupToolImageError { tool : " " . into ( ) , version : version_string . clone ( ) , dir : dest . clone ( ) , } ) ? ; progress . finish_and_clear ( ) ; // Note: We write this after the progress bar is finished to avoid display bugs with re-renders of the progress debug ! ( " " dest display ( ) ) ; Ok ( ( ) ) }
Unpack the yarn archive into the image directory so that it is ready for use
Unpack the yarn archive into the image directory so that it is ready for use
archive
Box<dyn Archive>
version
&Version
archive
Box<dyn Archive>
version
&Version