summaryrefslogtreecommitdiff
path: root/src/net/http_packages.rs
diff options
context:
space:
mode:
authorNamilskyy <alive6863@gmail.com>2025-11-29 20:48:12 +0300
committerNamilskyy <alive6863@gmail.com>2025-11-29 20:48:12 +0300
commit5319e24d9f7b43dbfdfd368ea5ac467970061cd2 (patch)
tree89eb1cb8f17962fe0f1bb8b97368a62875a60ded /src/net/http_packages.rs
parentd10ac4cc08d679e7971296b79c6eafadcdbc78de (diff)
Minor warnings fixed, implemented codeberg pages action
Diffstat (limited to 'src/net/http_packages.rs')
-rw-r--r--src/net/http_packages.rs49
1 files changed, 32 insertions, 17 deletions
diff --git a/src/net/http_packages.rs b/src/net/http_packages.rs
index 1e3c6ad..fe1833d 100644
--- a/src/net/http_packages.rs
+++ b/src/net/http_packages.rs
@@ -1,19 +1,21 @@
+use crate::cfg::config::Config;
use reqwest;
use std::fs::File;
use std::io::Write;
use std::path::Path;
-use crate::cfg::config::Config;
+#[allow(dead_code)]
pub struct HTTPPackage {
config: Config,
}
+#[allow(dead_code)]
impl HTTPPackage {
/// Creates a new Downloader object with the given configuration.
///
/// # Arguments
///
- /// * `config` - The full mesk
+ /// * `config` - The full mesk
///
/// # Returns
///
@@ -33,12 +35,11 @@ impl HTTPPackage {
/// # Returns
///
/// A new Config object with the parsed configuration. If there's an error while reading or parsing the file, returns an Err containing a Box<dyn std::error::Error>.
- pub fn parse_config(config_path: &str) -> Result<Config, Box<dyn std::error::Error>> {
+ pub fn parse_config() -> Result<Config, Box<dyn std::error::Error>> {
let config = Config::parse()?;
Ok(config)
}
-
/// Downloads the INDEX.tar.gz file from the configured repository
/// and stores it in the configured cache directory.
///
@@ -58,11 +59,9 @@ impl HTTPPackage {
let client = reqwest::Client::new();
- let response = client
- .get(&index_url)
- .send()
- .await
- .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Request failed: {}", e)))?;
+ let response = client.get(&index_url).send().await.map_err(|e| {
+ std::io::Error::new(std::io::ErrorKind::Other, format!("Request failed: {}", e))
+ })?;
if !response.status().is_success() {
return Err(std::io::Error::new(
@@ -74,19 +73,35 @@ impl HTTPPackage {
let index_data = response
.bytes()
.await
- .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to read response body: {}", e)))?
+ .map_err(|e| {
+ std::io::Error::new(
+ std::io::ErrorKind::Other,
+ format!("Failed to read response body: {}", e),
+ )
+ })?
.to_vec();
let file_path = Path::new(cache_dir).join("INDEX.tar.gz");
- let mut file = File::create(&file_path)
- .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to create file: {}", e)))?;
- file.write_all(&index_data)
- .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to write file: {}", e)))?;
- file.flush()
- .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to flush file: {}", e)))?;
+ let mut file = File::create(&file_path).map_err(|e| {
+ std::io::Error::new(
+ std::io::ErrorKind::Other,
+ format!("Failed to create file: {}", e),
+ )
+ })?;
+ file.write_all(&index_data).map_err(|e| {
+ std::io::Error::new(
+ std::io::ErrorKind::Other,
+ format!("Failed to write file: {}", e),
+ )
+ })?;
+ file.flush().map_err(|e| {
+ std::io::Error::new(
+ std::io::ErrorKind::Other,
+ format!("Failed to flush file: {}", e),
+ )
+ })?;
Ok(true)
}
}
-