summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cfg/config.rs1
-rw-r--r--src/lib.rs2
-rw-r--r--src/main.rs2
-rw-r--r--src/net/http_package.rs23
4 files changed, 14 insertions, 14 deletions
diff --git a/src/cfg/config.rs b/src/cfg/config.rs
index 213224f..af0def3 100644
--- a/src/cfg/config.rs
+++ b/src/cfg/config.rs
@@ -64,6 +64,7 @@ impl Config {
/// Return the default configuration as a toml string.
///
/// This function returns the default configuration as a toml string.
+ #[allow(clippy::should_implement_trait)]
pub fn default() -> Result<String, toml::ser::Error> {
let default: Config = Config {
repo: Repo {
diff --git a/src/lib.rs b/src/lib.rs
index ed6b426..b0717c0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,4 +1,3 @@
-
pub mod cfg {
pub mod config;
}
@@ -11,4 +10,3 @@ pub mod net {
pub mod pkgtoolkit {
pub mod pkgtools;
}
-
diff --git a/src/main.rs b/src/main.rs
index 4403c51..7010d0b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,5 @@
mod cfg;
-mod net;
+mod net;
mod pkgtoolkit;
use crate::cfg::config::Config;
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)