mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 22:30:03 +00:00
Move internal details of download to be internal to download (#314)
This commit is contained in:
parent
f38c1e73c3
commit
480ea19462
6 changed files with 11 additions and 16 deletions
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
|
@ -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)?;
|
|
@ -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,
|
Loading…
Add table
Add a link
Reference in a new issue