Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
jpcorreia99 committed Jul 26, 2024
1 parent 99e0c8e commit c232865
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions crates/rattler_package_streaming/src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
//! [`std::io::Read`] trait.
use super::{ExtractError, ExtractResult};
use rattler_digest::HashingReader;
use std::io::Cursor;
use std::mem::ManuallyDrop;
use std::{ffi::OsStr, io::Read, path::Path};
use rattler_digest::HashingReader;
use zip::read::{read_zipfile_from_stream, ZipArchive, ZipFile};

/// Returns the `.tar.bz2` as a decompressed `tar::Archive`. The `tar::Archive` can be used to
Expand Down Expand Up @@ -141,13 +141,15 @@ fn extract_zipfile(zip_file: ZipFile<'_>, destination: &Path) -> Result<(), Extr
Ok(())
}

fn compute_hashes<R: Read>(mut md5_reader: HashingReader<HashingReader<R, rattler_digest::Sha256>, rattler_digest::Md5>) -> Result<ExtractResult, ExtractError> {
// Read the file to the end to make sure the hash is properly computed.
std::io::copy(&mut md5_reader, &mut std::io::sink())?;
fn compute_hashes<R: Read>(
mut md5_reader: HashingReader<HashingReader<R, rattler_digest::Sha256>, rattler_digest::Md5>,
) -> Result<ExtractResult, ExtractError> {
// Read the file to the end to make sure the hash is properly computed.
std::io::copy(&mut md5_reader, &mut std::io::sink())?;

// Get the hashes
let (sha256_reader, md5) = md5_reader.finalize();
let (_, sha256) = sha256_reader.finalize();

// Get the hashes
let (sha256_reader, md5) = md5_reader.finalize();
let (_, sha256) = sha256_reader.finalize();

Ok(ExtractResult { sha256, md5 })
Ok(ExtractResult { sha256, md5 })
}

0 comments on commit c232865

Please sign in to comment.