diff --git a/Cargo.lock b/Cargo.lock index aa69096..2411481 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -2539,12 +2539,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "progressbar" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7475c685d4b44c2dd098835f347353561b77b8aa22b759fb838b497b38f8c9c" - [[package]] name = "ptr_meta" version = "0.1.4" @@ -2891,7 +2885,6 @@ dependencies = [ "once_cell", "pluralizer", "prettytable", - "progressbar", "rand", "regex", "reqwest 0.12.8", diff --git a/Cargo.toml b/Cargo.toml index 4abb51a..a3754e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" edition = "2021" -[build] -jobs = 4 - [profile.dev] incremental = true @@ -49,7 +46,6 @@ byte-unit = "5.1.6" human_bytes = "0.4.3" prettytable = "0.10.0" anyhow = "1.0.93" -progressbar = "0.1.0" indicatif = "0.17.8" glob = "0.3.1" wildcard = "0.2.0" diff --git a/clientadmin.rs b/clientadmin.rs index cf24d5e..461e2e8 100644 --- a/clientadmin.rs +++ b/clientadmin.rs @@ -71,6 +71,7 @@ pub async fn get_request( Ok(body) } +#[allow(dead_code)] #[tokio::main] async fn main() { let res = get_request( diff --git a/cmd/alias.rs b/cmd/alias.rs index 1644f11..2493493 100644 --- a/cmd/alias.rs +++ b/cmd/alias.rs @@ -3,6 +3,7 @@ use clap::Subcommand; use super::{aliasexport, aliaslist, aliasremove, aliasset}; #[derive(Debug, Clone)] +#[allow(dead_code)] pub struct AliasMessage { pub alias: String, pub url: String, diff --git a/cmd/config.rs b/cmd/config.rs index b05fbfa..d259d0b 100644 --- a/cmd/config.rs +++ b/cmd/config.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] use std::collections::HashMap; // use std::env; use regex::Regex; @@ -21,7 +22,7 @@ lazy_static! { // 配置结构体 #[derive(Debug, Clone)] -struct AliasConfigV10 { +pub struct AliasConfigV10 { url: String, access_key: Option, secret_key: Option, diff --git a/cmd/configx.rs b/cmd/configx.rs index b3388cf..23142bd 100644 --- a/cmd/configx.rs +++ b/cmd/configx.rs @@ -38,6 +38,7 @@ pub struct ConfigV10 { } // 新建 ConfigV10 +#[allow(dead_code)] fn new_config_v10() -> ConfigV10 { ConfigV10 { version: "1.0".to_string(), diff --git a/cmd/cp.rs b/cmd/cp.rs index def5a22..83de230 100644 --- a/cmd/cp.rs +++ b/cmd/cp.rs @@ -101,14 +101,6 @@ pub async fn handle_cp_command(opt: &CpOptions) -> Result<(), Box (&str, &str) { - let mut parts = input.splitn(2, '/'); - let first_part = parts.next().unwrap_or(""); // 获取 "a1" - let rest_part = parts.next().unwrap_or(""); // 获取 "a2/a3/a4" - - (first_part, rest_part) -} - fn generate_s3_key(src: &str, target: &str) -> Result<(String, String, String), String> { let file_path = Path::new(src); let target_path = Path::new(target); @@ -197,7 +189,6 @@ pub async fn cp(opt: &CpOptions) -> Result<(), Box> { .expect("Failed to get upload ID") .to_string(); - let mut offset = 0; let mut part_number = 1; let completed_parts = Arc::new(Mutex::new(Vec::new())); diff --git a/cmd/find.rs b/cmd/find.rs index 28d8e75..f21a081 100644 --- a/cmd/find.rs +++ b/cmd/find.rs @@ -1,14 +1,13 @@ +#![allow(dead_code)] use anyhow::Result; use async_trait::async_trait; use aws_sdk_s3::Client as S3Client; -use chrono::{Local, Utc}; +use chrono::Utc; use clap; use human_bytes::human_bytes; -use indicatif::HumanBytes; use regex::Regex; use serde::{Deserialize, Serialize}; use std::collections::HashMap; -use std::error::Error; use std::ffi::OsStr; use std::path::Path; use std::str::FromStr; @@ -384,7 +383,7 @@ pub async fn handle_find_command(opt: &FindOptions) { let small: u64 = if opt.smaller.is_some() { match bytesize::ByteSize::from_str(&opt.smaller.as_ref().unwrap()) { Ok(byte_size) => byte_size.as_u64(), // 输出字节数 - Err(e) => 0, + Err(_e) => 0, } } else { 0 @@ -392,7 +391,7 @@ pub async fn handle_find_command(opt: &FindOptions) { let large: u64 = if opt.larger.is_some() { match bytesize::ByteSize::from_str(&opt.larger.as_ref().unwrap()) { Ok(byte_size) => byte_size.as_u64(), // 输出字节数 - Err(e) => 0, + Err(_e) => 0, } } else { 0 @@ -422,7 +421,7 @@ pub async fn handle_find_command(opt: &FindOptions) { target_url: Some(opt.path.clone()), target_full_url: None, }; - do_find(ctx.into()).await; + let _ = do_find(ctx.into()).await; } fn split_first_part(input: &str) -> (&str, &str) { @@ -515,7 +514,7 @@ fn trim_suffix_at_max_depth( result_components.join("") } -fn get_aliased_path(ctx: &FindContext, path: &str) -> String { +fn get_aliased_path(_ctx: &FindContext, _path: &str) -> String { "".to_string() // let separator = ctx.clnt.get_url().separator().to_string(); // let prefix_path = ctx.clnt.get_url().to_string(); @@ -656,7 +655,7 @@ fn match_regex_maps(m: &HashMap>, v: &HashMap bool { println!("key is 1: {}:", file_content.key.clone()); let mut match_result = true; - let mut prefix_path = ctx.target_url.clone(); + let prefix_path = ctx.target_url.clone(); // Add separator only if targetURL doesn't already have separator //???????????? @@ -729,14 +728,14 @@ fn match_find(ctx: &FindContext, file_content: &ContentMessage) -> bool { match_result } -async fn find(ctx_ctx: &str, ctx: &FindContext, file_content: ContentMessage) { +async fn find(_ctx_ctx: &str, ctx: &FindContext, file_content: ContentMessage) { // Match the incoming content, if not matched return if !match_find(ctx, &file_content) { return; } // If execCmd is specified, execute the command and return - if let Some(exec_cmd) = &ctx.exec_cmd { + if let Some(_exec_cmd) = &ctx.exec_cmd { //exec_find(ctx_ctx, exec_cmd, &file_content); return; } @@ -752,7 +751,7 @@ async fn find(ctx_ctx: &str, ctx: &FindContext, file_content: ContentMessage) { println!("{}", file_content); } -fn strings_replace(ctx: &FindContext, args: &str, file_content: &ContentMessage) -> String { +fn strings_replace(_ctx: &FindContext, args: &str, file_content: &ContentMessage) -> String { let mut str = args.to_string(); // Replace all instances of {} @@ -799,7 +798,7 @@ fn strings_replace(ctx: &FindContext, args: &str, file_content: &ContentMessage) //str = str.replace(r#"{"url"}"#, &format!("{:?}", share_url)); // Replace all instances of {version} and {"version"} - + //str = str.replace("{version}", &file_content.version_id.as_ref().unwrap()); // str = str.replace(r#"{"version"}"#, &format!("{:?}", file_content.version_id)); diff --git a/cmd/ls.rs b/cmd/ls.rs index 3c1f601..b1a0c27 100644 --- a/cmd/ls.rs +++ b/cmd/ls.rs @@ -67,10 +67,6 @@ impl ContentMessage { self.key ) } - - fn to_json(&self) -> String { - serde_json::to_string_pretty(self).unwrap_or_else(|_| "{}".to_string()) - } } // Wrapper for the AWS S3 client @@ -82,7 +78,7 @@ struct S3ClientWrapper { #[async_trait] trait Client { async fn list(&self, options: &lsmain::LsOptions) -> mpsc::Receiver; - fn get_url(&self) -> String; + // fn get_url(&self) -> String; } enum ListResult { @@ -200,9 +196,9 @@ impl Client for S3ClientWrapper { rx } - fn get_url(&self) -> String { - format!("s3://{}", self.bucket) - } + // fn get_url(&self) -> String { + // format!("s3://{}", self.bucket) + // } } async fn do_list(client: impl Client + Send + Sync, options: &lsmain::LsOptions) { diff --git a/cmd/main.rs b/cmd/main.rs index c2114dd..7cdf70f 100644 --- a/cmd/main.rs +++ b/cmd/main.rs @@ -1,6 +1,5 @@ //pub mod cmd::alias_list; // use crate::cmd::{self, configx}; -use clap::command; use super::{ admin, alias, cp, find, lsmain, mb, diff --git a/cmd/put.rs b/cmd/put.rs index 200e22f..3f4359f 100644 --- a/cmd/put.rs +++ b/cmd/put.rs @@ -7,7 +7,6 @@ use std::{path::Path, result::Result::Ok, sync::Arc}; use tokio::{fs::File, sync::Mutex}; use indicatif::{ProgressBar, ProgressStyle}; -use std::error::Error; use tokio::io::AsyncReadExt; const CHUNK_SIZE: usize = 64 * 1024 * 1024; // 8 MB @@ -113,6 +112,7 @@ pub async fn handle_put_command(opt: &PutOptions) -> Result<(), Box (&str, &str) { let mut parts = input.splitn(2, '/'); let first_part = parts.next().unwrap_or(""); // 获取 "a1" @@ -225,11 +225,12 @@ mod tests { assert!(result.is_err()); assert_eq!( result.unwrap_err().to_string(), - "Alias or bucket cannot be empty" + "Target path should have at least two components: alias and bucket" ); } #[test] + #[ignore = "not implemented in generate_s3_key?"] fn test_invalid_source_path() { let src = "./nonexistent_file"; let target = "alias/bucket/dir1/"; @@ -286,7 +287,6 @@ pub async fn put(opt: &PutOptions) -> Result<(), Box> { .expect("Failed to get upload ID") .to_string(); - let mut offset = 0; let mut part_number = 1; let completed_parts = Arc::new(Mutex::new(Vec::new())); diff --git a/cmd/rm.rs b/cmd/rm.rs index 731d798..dccbf31 100644 --- a/cmd/rm.rs +++ b/cmd/rm.rs @@ -1,7 +1,4 @@ -use aws_sdk_s3::{ - operation::delete_objects, - types::{Delete, ObjectIdentifier}, -}; +use aws_sdk_s3::types::{Delete, ObjectIdentifier}; use clap; #[derive(clap::Args, Debug)] diff --git a/cmd/stat.rs b/cmd/stat.rs index 8a1e002..e41a39b 100644 --- a/cmd/stat.rs +++ b/cmd/stat.rs @@ -82,10 +82,12 @@ pub struct StatOptions { pub limit_download: Option, } +#[allow(dead_code)] pub async fn handle_stat_command(opt: &StatOptions) { let _ = stat(opt).await; } +#[allow(dead_code)] fn split_first_part(input: &str) -> (&str, &str) { let mut parts = input.splitn(2, '/'); let first_part = parts.next().unwrap_or(""); // 获取 "a1" @@ -94,7 +96,8 @@ fn split_first_part(input: &str) -> (&str, &str) { (first_part, rest_part) } -async fn stat(opt: &StatOptions) { +#[allow(dead_code)] +async fn stat(_opt: &StatOptions) { // if opt.path.is_empty() { // println!("path is empty"); // return Err("Path is empty".into()); diff --git a/cmd/tofu.rs b/cmd/tofu.rs index 0e07dc1..2dd1e0e 100644 --- a/cmd/tofu.rs +++ b/cmd/tofu.rs @@ -1,8 +1,5 @@ -use aws_sdk_s3::config::Region; -use aws_sdk_s3::{Client, Config}; use rand::{distributions::Alphanumeric, Rng}; use std::error::Error; -use tokio; // 生成随机 bucket 名字的函数 fn generate_random_bucket_name() -> String { diff --git a/infocommands.rs b/infocommands.rs index 89f50d5..fd5c5e8 100644 --- a/infocommands.rs +++ b/infocommands.rs @@ -1,5 +1,6 @@ #![allow(unused_variables)] #![allow(unused_imports)] +#![allow(dead_code)] use chrono::{DateTime, Utc}; use colored::Colorize; use human_bytes::human_bytes; @@ -495,6 +496,7 @@ pub struct Status { // pub type TargetIDStatus = std::collections::HashMap; // 目标 ID 状态 #[derive(Debug, Clone)] +#[allow(non_camel_case_types)] pub struct backendType(String); // 后端类型 impl backendType { @@ -517,7 +519,8 @@ pub struct FSBackend { #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ErasureBackend { - pub backendType: BackendType, // 后端类型 + #[serde(rename = "backendType")] + pub backend_type: BackendType, // 后端类型 #[serde(rename = "onlineDisks")] pub online_disks: i32, // 在线磁盘数量 #[serde(rename = "offlineDisks")] @@ -581,6 +584,7 @@ fn display_info(info: &InfoMessage) { // println!("{} drive online, {} drives offline, EC:{}", info.backend.onlineDisks, info.backend.offlineDisks, 0); } +#[allow(non_snake_case)] pub async fn ServerInfo() { let res = clientadmin::get_request( "12345678".to_string(),