From 5a5712fde0f6e3c97cbdf3b6b82e9ef95523bfe6 Mon Sep 17 00:00:00 2001 From: weisd Date: Mon, 23 Jun 2025 10:28:57 +0800 Subject: [PATCH] fix clippy --- crates/notify/src/event.rs | 8 ++------ crates/notify/src/global.rs | 2 +- crates/notify/src/integration.rs | 15 +++------------ crates/utils/src/sys/user_agent.rs | 2 +- rustfs/src/main.rs | 8 +++----- 5 files changed, 10 insertions(+), 25 deletions(-) diff --git a/crates/notify/src/event.rs b/crates/notify/src/event.rs index 829c4f43b..6c7c30f44 100644 --- a/crates/notify/src/event.rs +++ b/crates/notify/src/event.rs @@ -445,12 +445,8 @@ impl Event { }; let mut resp_elements = args.resp_elements.clone(); - resp_elements - .entry("x-amz-request-id".to_string()) - .or_insert_with(|| "".to_string()); - resp_elements - .entry("x-amz-id-2".to_string()) - .or_insert_with(|| "".to_string()); + resp_elements.entry("x-amz-request-id".to_string()).or_default(); + resp_elements.entry("x-amz-id-2".to_string()).or_default(); // ... Filling of other response elements // URL encoding of object keys diff --git a/crates/notify/src/global.rs b/crates/notify/src/global.rs index f2b954397..71418390d 100644 --- a/crates/notify/src/global.rs +++ b/crates/notify/src/global.rs @@ -54,7 +54,7 @@ impl Notifier { // Create an event and send it let event = Event::new(args.clone()); notification_sys - .send_event(&args.bucket_name, &args.event_name.as_str(), &args.object.name.clone(), event) + .send_event(&args.bucket_name, args.event_name.as_str(), args.object.name.as_str(), event) .await; } } diff --git a/crates/notify/src/integration.rs b/crates/notify/src/integration.rs index b6d247520..669cbf907 100644 --- a/crates/notify/src/integration.rs +++ b/crates/notify/src/integration.rs @@ -189,10 +189,7 @@ impl NotificationSystem { info!("Attempting to remove target: {}", target_id); let Some(store) = ecstore::global::new_object_layer_fn() else { - return Err(NotificationError::Io(std::io::Error::new( - std::io::ErrorKind::Other, - "errServerNotInitialized", - ))); + return Err(NotificationError::Io(std::io::Error::other("errServerNotInitialized"))); }; let mut new_config = ecstore::config::com::read_config_without_migrate(store.clone()) @@ -243,10 +240,7 @@ impl NotificationSystem { info!("Setting config for target {} of type {}", target_name, target_type); // 1. Get the storage handle let Some(store) = ecstore::global::new_object_layer_fn() else { - return Err(NotificationError::Io(std::io::Error::new( - std::io::ErrorKind::Other, - "errServerNotInitialized", - ))); + return Err(NotificationError::Io(std::io::Error::other("errServerNotInitialized"))); }; // 2. Read the latest configuration from storage @@ -306,10 +300,7 @@ impl NotificationSystem { pub async fn remove_target_config(&self, target_type: &str, target_name: &str) -> Result<(), NotificationError> { info!("Removing config for target {} of type {}", target_name, target_type); let Some(store) = ecstore::global::new_object_layer_fn() else { - return Err(NotificationError::Io(std::io::Error::new( - std::io::ErrorKind::Other, - "errServerNotInitialized", - ))); + return Err(NotificationError::Io(std::io::Error::other("errServerNotInitialized"))); }; let mut new_config = ecstore::config::com::read_config_without_migrate(store.clone()) diff --git a/crates/utils/src/sys/user_agent.rs b/crates/utils/src/sys/user_agent.rs index 31f42fd7e..efc0f62e8 100644 --- a/crates/utils/src/sys/user_agent.rs +++ b/crates/utils/src/sys/user_agent.rs @@ -100,7 +100,7 @@ impl UserAgent { fn get_macos_platform(_sys: &System) -> String { let binding = System::os_version().unwrap_or("14.5.0".to_string()); let version = binding.split('.').collect::>(); - let major = version.get(0).unwrap_or(&"14").to_string(); + let major = version.first().unwrap_or(&"14").to_string(); let minor = version.get(1).unwrap_or(&"5").to_string(); let patch = version.get(2).unwrap_or(&"0").to_string(); diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index ae915ff24..e2dae1718 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -502,11 +502,9 @@ async fn run(opt: config::Opt) -> Result<()> { }); // init store - let store = ECStore::new(server_addr.clone(), endpoint_pools.clone()) - .await - .inspect_err(|err| { - error!("ECStore::new {:?}", err); - })?; + let store = ECStore::new(server_addr, endpoint_pools.clone()).await.inspect_err(|err| { + error!("ECStore::new {:?}", err); + })?; ecconfig::init(); // config system configuration