diff options
| author | Namilskyy <alive6863@gmail.com> | 2025-12-01 14:17:47 +0300 |
|---|---|---|
| committer | Namilskyy <alive6863@gmail.com> | 2025-12-01 14:17:47 +0300 |
| commit | b157e34176858766738be7e6903cc188285a5aeb (patch) | |
| tree | 5a58fbb2eda53cb4c3fd131f2457fb9639285ad6 /src/net/http_package.rs | |
| parent | 3fc368fbd6a818a8f9f210c995d82725d11e6e45 (diff) | |
Formatted code && fix clippy warn
Diffstat (limited to 'src/net/http_package.rs')
| -rw-r--r-- | src/net/http_package.rs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/net/http_package.rs b/src/net/http_package.rs index ade4ee1..aeff588 100644 --- a/src/net/http_package.rs +++ b/src/net/http_package.rs @@ -1,14 +1,14 @@ use crate::cfg::config::Config; use crate::pkgtoolkit::pkgtools::Package; +use flate2::read::GzDecoder; use futures_util::stream::TryStreamExt; use indicatif::{ProgressBar, ProgressStyle}; use reqwest; use serde::Deserialize; -use std::{ collections::HashMap, path::Path }; -use tokio::{ fs::File, io::AsyncWriteExt}; use std::fs::File as StdFile; -use flate2::read::GzDecoder; -use tar::Archive; +use std::{collections::HashMap, path::Path}; +use tar::Archive; +use tokio::{fs::File, io::AsyncWriteExt}; pub struct HTTPPackage { pub config: Config, @@ -90,7 +90,8 @@ impl HTTPPackage { let file_path = Path::new(cache_dir).join("INDEX.tar.gz"); // Ensure cache_dir exists - tokio::fs::create_dir_all(cache_dir).await + tokio::fs::create_dir_all(cache_dir) + .await .map_err(|e| format!("Failed to create cache dir: {}", e))?; let mut file = File::create(&file_path).await?; @@ -108,12 +109,12 @@ impl HTTPPackage { log::info!("Extracting INDEX.tar.gz to cache directory..."); // Package::extract_archive(&file_path.to_string_lossy())?; - - let archive_file = StdFile::open(&file_path) - .map_err(|e| format!("Failed to open archive: {}", e))?; + let archive_file = + StdFile::open(&file_path).map_err(|e| format!("Failed to open archive: {}", e))?; let gz_decoder = GzDecoder::new(archive_file); let mut archive = Archive::new(gz_decoder); - archive.unpack(cache_dir) + archive + .unpack(cache_dir) .map_err(|e| format!("Failed to unpack archive: {}", e))?; let index_toml_path = Path::new(cache_dir).join("INDEX.toml"); @@ -146,7 +147,7 @@ impl HTTPPackage { ); Ok(true) -} + } /// An internal auxiliary function for downloading data and writing it to a file with a progress display. /// @@ -227,7 +228,7 @@ impl HTTPPackage { ) -> Result<bool, Box<dyn std::error::Error>> { let package_info = self.fetch_package_info(package_name)?; let url = &package_info.url; - + let client = reqwest::Client::new(); let file_name = Path::new(url) |
