pub fn fetch(url: &str, cache_file: &Path) -> Result<Box<dyn Archive>, failure::Error> {
        let response = reqwest::get(url)?;

        if !response.status().is_success() {
            return Err(super::HttpError {
                code: response.status(),
            }
            .into());
        }

        let compressed_size = content_length(&response)?;
        let uncompressed_size = if accepts_byte_ranges(&response) {
            fetch_uncompressed_size(url, compressed_size)
        } else {
            None
        };

        ensure_containing_dir_exists(&cache_file)?;
        let file = File::create(cache_file)?;
        let data = Box::new(TeeReader::new(response, file));

        Ok(Box::new(Tarball {
            uncompressed_size,
            compressed_size,
            data,
            origin: Origin::Remote,
        }))
    }
/// Initiate fetching of a tarball from the given URL, returning a
/// tarball that can be streamed (and that tees its data to a local
/// file as it streams).
Initiate fetching of a tarball from the given URL, returning a
tarball that can be streamed (and that tees its data to a local
file as it streams).
Initiate fetching of a tarball from the given URL returning a tarball that can be streamed ( and that tees its data to a local file as it streams ) .
pub fn fetch(url: &str, cache_file: &Path) -> Result<Box<dyn Archive>, failure::Error> {
        let response = reqwest::get(url)?;
        if !response.status().is_success() {
            return Err(super::HttpError {
                code: response.status(),
            }
            .into());
        }
        let compressed_size = content_length(&response)?;
        let uncompressed_size = if accepts_byte_ranges(&response) {
            fetch_uncompressed_size(url, compressed_size)
        } else {
            None
        };
        ensure_containing_dir_exists(&cache_file)?;
        let file = File::create(cache_file)?;
        let data = Box::new(TeeReader::new(response, file));
        Ok(Box::new(Tarball {
            uncompressed_size,
            compressed_size,
            data,
            origin: Origin::Remote,
        }))
    }
pub fn fetch ( url : & str , cache_file : & Path ) -> Result < Box < dyn Archive > , failure :: Error > { let response = reqwest :: get ( url ) ? ; if ! response . status ( ) . is_success ( ) { return Err ( super :: HttpError { code : response . status ( ) , } . into ( ) ) ; } let compressed_size = content_length ( & response ) ? ; let uncompressed_size = if accepts_byte_ranges ( & response ) { fetch_uncompressed_size ( url , compressed_size ) } else { None } ; ensure_containing_dir_exists ( & cache_file ) ? ; let file = File :: create ( cache_file ) ? ; let data = Box :: new ( TeeReader :: new ( response , file ) ) ; Ok ( Box :: new ( Tarball { uncompressed_size , compressed_size , data , origin : Origin :: Remote , } ) ) }
Initiate fetching of a tarball from the given URL, returning a
tarball that can be streamed (and that tees its data to a local
file as it streams).
Initiate fetching of a tarball from the given URL returning a tarball that can be streamed ( and that tees its data to a local file as it streams ) .
url
&str
cache_file
&Path
url
&str
cache_file
&Path