mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-28 09:08:58 +00:00
refactor: remove unused methods and dependencies
1. Removed unused `unzip_file` and `download_file` methods from `utils/helper.rs`. 2. Removed `reqwest` and `zip` crates from `Cargo.toml`.
This commit is contained in:
@@ -13,16 +13,15 @@ dirs = { workspace = true }
|
||||
futures-util = { workspace = true }
|
||||
hex = { workspace = true }
|
||||
keyring = { workspace = true }
|
||||
reqwest = { workspace = true }
|
||||
lazy_static = { workspace = true }
|
||||
rfd = { workspace = true }
|
||||
rust-embed = { workspace = true }
|
||||
rust-embed = { workspace = true, features = ["interpolate-folder-path"] }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
sha2 = { workspace = true }
|
||||
tokio = { workspace = true, features = ["io-util", "net", "process", "sync"] }
|
||||
tracing-subscriber = { workspace = true, features = ["fmt", "env-filter", "tracing-log", "time", "local-time", "json"] }
|
||||
tracing-appender = { workspace = true }
|
||||
zip = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["desktop"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::components::navbar::LoadingSpinner;
|
||||
use crate::router::Route;
|
||||
use crate::route::Route;
|
||||
use crate::utils::{RustFSConfig, ServiceManager};
|
||||
use chrono::Datelike;
|
||||
use dioxus::logger::tracing::debug;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::router::Route;
|
||||
use crate::route::Route;
|
||||
use dioxus::logger::tracing::debug;
|
||||
use dioxus::prelude::*;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
mod components;
|
||||
mod router;
|
||||
mod route;
|
||||
mod utils;
|
||||
mod views;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::utils::RustFSConfig;
|
||||
use dioxus::logger::tracing::{debug, error, info};
|
||||
use futures_util::TryStreamExt;
|
||||
use lazy_static::lazy_static;
|
||||
use rust_embed::RustEmbed;
|
||||
use sha2::{Digest, Sha256};
|
||||
@@ -205,72 +204,10 @@ impl ServiceManager {
|
||||
perms.set_mode(0o755);
|
||||
std::fs::set_permissions(&executable_path, perms)?;
|
||||
}
|
||||
// Self::show_info("服务程序已成功下载并准备就绪");
|
||||
// }
|
||||
|
||||
Ok(executable_path)
|
||||
}
|
||||
|
||||
/// Download the file
|
||||
/// This function is a modified version of the example from the `reqwest` crate documentation
|
||||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// let url = "https://api.xmb.xyz/download/rustfs.zip";
|
||||
/// let path = Path::new("rustfs.zip");
|
||||
/// download_file(url, path).await;
|
||||
/// ```
|
||||
async fn download_file(url: &str, path: &Path) -> Result<(), Box<dyn Error>> {
|
||||
let client = reqwest::Client::new();
|
||||
let res = client.get(url).send().await?;
|
||||
|
||||
if !res.status().is_success() {
|
||||
return Err(format!("下载失败:{}", res.status()).into());
|
||||
}
|
||||
|
||||
let mut file = tokio::fs::File::create(path).await?;
|
||||
let mut stream = res.bytes_stream();
|
||||
while let Ok(Some(chunk)) = stream.try_next().await {
|
||||
file.write_all(&chunk).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// unzip the file
|
||||
/// This function is a modified version of the example from the `zip` crate documentation
|
||||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// let zip_path = Path::new("rustfs.zip");
|
||||
/// let extract_path = Path::new("rustfs");
|
||||
/// unzip_file(zip_path, extract_path);
|
||||
/// ```
|
||||
async fn unzip_file(zip_path: &Path, extract_path: &Path) -> Result<(), Box<dyn Error>> {
|
||||
use std::fs::File;
|
||||
let file = File::open(zip_path)?;
|
||||
let mut archive = zip::ZipArchive::new(file)?;
|
||||
|
||||
for i in 0..archive.len() {
|
||||
let mut file = archive.by_index(i)?;
|
||||
let out_path = extract_path.join(file.name());
|
||||
|
||||
if file.name().ends_with('/') {
|
||||
std::fs::create_dir_all(&out_path)?;
|
||||
} else {
|
||||
if let Some(p) = out_path.parent() {
|
||||
if !p.exists() {
|
||||
std::fs::create_dir_all(p)?;
|
||||
}
|
||||
}
|
||||
let mut outfile = File::create(&out_path)?;
|
||||
std::io::copy(&mut file, &mut outfile)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Helper function: Extracts the port from the address string
|
||||
///
|
||||
/// # Example
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::router::Route;
|
||||
use crate::route::Route;
|
||||
use dioxus::logger::tracing::info;
|
||||
use dioxus::prelude::*;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user