Skip to content

Commit

Permalink
refactor: remove unnecessary function (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
KSXGitHub authored Nov 22, 2023
1 parent c98128d commit 4d246d6
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions crates/tarball/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use pacquet_store_dir::{
PackageFileInfo, PackageFilesIndex, StoreDir, WriteCasFileError, WriteIndexFileError,
};
use pipe_trait::Pipe;
use ssri::{Integrity, IntegrityChecker};
use ssri::Integrity;
use tar::Archive;
use tokio::sync::{Notify, RwLock};
use tracing::instrument;
Expand Down Expand Up @@ -103,11 +103,6 @@ fn decompress_gzip(gz_data: &[u8], unpacked_size: Option<usize>) -> Result<Vec<u
.map_err(TarballError::DecodeGzip)
}

#[instrument(skip(data), fields(data_len = data.len()))]
fn verify_checksum(data: &[u8], integrity: Integrity) -> Result<ssri::Algorithm, ssri::Error> {
integrity.pipe(IntegrityChecker::new).chain(data).result()
}

/// This subroutine downloads and extracts a tarball to the store directory.
///
/// It returns a CAS map of files in the tarball.
Expand Down Expand Up @@ -200,7 +195,7 @@ impl<'a> DownloadTarballToStore<'a> {
Other(TarballError),
}
let cas_paths = tokio::task::spawn(async move {
verify_checksum(&response, package_integrity.clone()).map_err(TaskError::Checksum)?;
package_integrity.check(&response).map_err(TaskError::Checksum)?;

// TODO: move tarball extraction to its own function
// TODO: test it
Expand Down

0 comments on commit 4d246d6

Please sign in to comment.