summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/http_package.rs23
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)