diff --git a/crates/lib/src/drivers/crates_io/visitor.rs b/crates/lib/src/drivers/crates_io/visitor.rs index 01a71d39..f36cae9d 100644 --- a/crates/lib/src/drivers/crates_io/visitor.rs +++ b/crates/lib/src/drivers/crates_io/visitor.rs @@ -10,7 +10,7 @@ use tar::Entries; use super::vfs::Vfs; use crate::{ - errors::BinstallError, helpers::async_extracter::TarEntriesVisitor, + errors::BinstallError, helpers::download::TarEntriesVisitor, manifests::cargo_toml_binstall::Meta, }; diff --git a/crates/lib/src/helpers.rs b/crates/lib/src/helpers.rs index 16ade8b4..ddae0132 100644 --- a/crates/lib/src/helpers.rs +++ b/crates/lib/src/helpers.rs @@ -1,9 +1,6 @@ -pub mod async_extracter; pub mod download; -pub mod extracter; pub mod jobserver_client; pub mod remote; pub mod signal; pub mod statics; -pub mod stream_readable; pub mod tasks; diff --git a/crates/lib/src/helpers/download.rs b/crates/lib/src/helpers/download.rs index 25d94f49..987805a6 100644 --- a/crates/lib/src/helpers/download.rs +++ b/crates/lib/src/helpers/download.rs @@ -5,17 +5,16 @@ use reqwest::{Client, Url}; use crate::{ errors::BinstallError, - helpers::{ - async_extracter::{ - extract_bin, extract_tar_based_stream, extract_tar_based_stream_and_visit, extract_zip, - }, - remote::create_request, - }, + helpers::remote::create_request, manifests::cargo_toml_binstall::{PkgFmt, PkgFmtDecomposed, TarBasedFmt}, }; -use super::async_extracter::TarEntriesVisitor; +pub use async_extracter::TarEntriesVisitor; +use async_extracter::*; +mod async_extracter; +mod extracter; +mod stream_readable; /// Download a file from the provided URL and extract it to the provided path. pub async fn download_and_extract<P: AsRef<Path>>( client: &Client, diff --git a/crates/lib/src/helpers/async_extracter.rs b/crates/lib/src/helpers/download/async_extracter.rs similarity index 99% rename from crates/lib/src/helpers/async_extracter.rs rename to crates/lib/src/helpers/download/async_extracter.rs index 844fbc0b..682c2c5f 100644 --- a/crates/lib/src/helpers/async_extracter.rs +++ b/crates/lib/src/helpers/download/async_extracter.rs @@ -13,9 +13,8 @@ use tar::Entries; use tempfile::tempfile; use tokio::task::block_in_place; -use crate::{errors::BinstallError, manifests::cargo_toml_binstall::TarBasedFmt}; - use super::{extracter::*, stream_readable::StreamReadable}; +use crate::{errors::BinstallError, manifests::cargo_toml_binstall::TarBasedFmt}; pub async fn extract_bin<S, E>(stream: S, path: &Path) -> Result<(), BinstallError> where diff --git a/crates/lib/src/helpers/extracter.rs b/crates/lib/src/helpers/download/extracter.rs similarity index 91% rename from crates/lib/src/helpers/extracter.rs rename to crates/lib/src/helpers/download/extracter.rs index 43fa6d3c..86ebe5f5 100644 --- a/crates/lib/src/helpers/extracter.rs +++ b/crates/lib/src/helpers/download/extracter.rs @@ -14,7 +14,7 @@ use zstd::stream::Decoder as ZstdDecoder; use crate::{errors::BinstallError, manifests::cargo_toml_binstall::TarBasedFmt}; -pub(super) fn create_tar_decoder( +pub fn create_tar_decoder( dat: impl BufRead + 'static, fmt: TarBasedFmt, ) -> io::Result<Archive<Box<dyn Read>>> { @@ -36,7 +36,7 @@ pub(super) fn create_tar_decoder( Ok(Archive::new(r)) } -pub(super) fn unzip(dat: File, dst: &Path) -> Result<(), BinstallError> { +pub fn unzip(dat: File, dst: &Path) -> Result<(), BinstallError> { debug!("Decompressing from zip archive to `{dst:?}`"); let mut zip = ZipArchive::new(dat)?; diff --git a/crates/lib/src/helpers/stream_readable.rs b/crates/lib/src/helpers/download/stream_readable.rs similarity index 98% rename from crates/lib/src/helpers/stream_readable.rs rename to crates/lib/src/helpers/download/stream_readable.rs index 0f26d0a1..bc450fb5 100644 --- a/crates/lib/src/helpers/stream_readable.rs +++ b/crates/lib/src/helpers/download/stream_readable.rs @@ -15,7 +15,7 @@ use crate::errors::BinstallError; /// `tokio::task::{block_in_place, spawn_blocking}` or /// `std::thread::spawn`. #[derive(Debug)] -pub(super) struct StreamReadable<S> { +pub struct StreamReadable<S> { stream: S, handle: Handle, bytes: Bytes,