diff --git a/crates/filemeta/src/filemeta.rs b/crates/filemeta/src/filemeta.rs index d814863a..57557fdf 100644 --- a/crates/filemeta/src/filemeta.rs +++ b/crates/filemeta/src/filemeta.rs @@ -929,13 +929,17 @@ impl FileMetaVersion { } pub fn get_data_dir(&self) -> Option { - if self.valid() { { + if self.valid() { + { if self.version_type == VersionType::Object { self.object.as_ref().map(|v| v.data_dir).unwrap_or_default() } else { None } - } } else { Default::default() } + } + } else { + Default::default() + } } pub fn get_version_id(&self) -> Option { diff --git a/crates/notify/src/target/mqtt.rs b/crates/notify/src/target/mqtt.rs index f69cf433..0584a5ac 100644 --- a/crates/notify/src/target/mqtt.rs +++ b/crates/notify/src/target/mqtt.rs @@ -241,8 +241,7 @@ impl MQTTTarget { records: vec![event.clone()], }; - let data = - serde_json::to_vec(&log).map_err(|e| TargetError::Serialization(format!("Failed to serialize event: {e}")))?; + let data = serde_json::to_vec(&log).map_err(|e| TargetError::Serialization(format!("Failed to serialize event: {e}")))?; // Vec Convert to String, only for printing logs let data_string = String::from_utf8(data.clone()) diff --git a/crates/notify/src/target/webhook.rs b/crates/notify/src/target/webhook.rs index 6d49b9e1..adc426bc 100644 --- a/crates/notify/src/target/webhook.rs +++ b/crates/notify/src/target/webhook.rs @@ -206,8 +206,7 @@ impl WebhookTarget { records: vec![event.clone()], }; - let data = - serde_json::to_vec(&log).map_err(|e| TargetError::Serialization(format!("Failed to serialize event: {e}")))?; + let data = serde_json::to_vec(&log).map_err(|e| TargetError::Serialization(format!("Failed to serialize event: {e}")))?; // Vec Convert to String let data_string = String::from_utf8(data.clone()) diff --git a/crates/obs/src/telemetry.rs b/crates/obs/src/telemetry.rs index e8f8c130..fe71e343 100644 --- a/crates/obs/src/telemetry.rs +++ b/crates/obs/src/telemetry.rs @@ -333,9 +333,7 @@ pub(crate) fn init_telemetry(config: &OtelConfig) -> OtelGuard { // Configure the flexi_logger let flexi_logger_result = flexi_logger::Logger::try_with_env_or_str(logger_level) .unwrap_or_else(|e| { - eprintln!( - "Invalid logger level: {logger_level}, using default: {DEFAULT_LOG_LEVEL}, failed error: {e:?}" - ); + eprintln!("Invalid logger level: {logger_level}, using default: {DEFAULT_LOG_LEVEL}, failed error: {e:?}"); flexi_logger::Logger::with(log_spec.clone()) }) .log_to_file( diff --git a/crates/rio/src/hash_reader.rs b/crates/rio/src/hash_reader.rs index 3dca03e3..d00721d1 100644 --- a/crates/rio/src/hash_reader.rs +++ b/crates/rio/src/hash_reader.rs @@ -484,9 +484,7 @@ mod tests { } // 验证 etag(注意:压缩会改变数据,所以这里的 etag 验证可能需要调整) - println!( - "Test completed successfully with compression: {is_compress}, encryption: {is_encrypt}" - ); + println!("Test completed successfully with compression: {is_compress}, encryption: {is_encrypt}"); } #[tokio::test] diff --git a/crates/utils/src/certs.rs b/crates/utils/src/certs.rs index fc20e94c..d5528b29 100644 --- a/crates/utils/src/certs.rs +++ b/crates/utils/src/certs.rs @@ -22,9 +22,7 @@ pub fn load_certs(filename: &str) -> io::Result>> { .collect::, _>>() .map_err(|e| certs_error(format!("certificate file {filename} format error:{e:?}")))?; if certs.is_empty() { - return Err(certs_error(format!( - "No valid certificate was found in the certificate file {filename}" - ))); + return Err(certs_error(format!("No valid certificate was found in the certificate file {filename}"))); } Ok(certs) } diff --git a/ecstore/src/config/heal.rs b/ecstore/src/config/heal.rs index fbdb195b..64241060 100644 --- a/ecstore/src/config/heal.rs +++ b/ecstore/src/config/heal.rs @@ -47,9 +47,7 @@ fn parse_bitrot_config(s: &str) -> Result { match s.trim_end_matches('m').parse::() { Ok(months) => { if months < RUSTFS_BITROT_CYCLE_IN_MONTHS { - return Err(Error::other(format!( - "minimum bitrot cycle is {RUSTFS_BITROT_CYCLE_IN_MONTHS} month(s)" - ))); + return Err(Error::other(format!("minimum bitrot cycle is {RUSTFS_BITROT_CYCLE_IN_MONTHS} month(s)"))); } Ok(Duration::from_secs(months * 30 * 24 * 60)) diff --git a/ecstore/src/disk/local.rs b/ecstore/src/disk/local.rs index 0259891b..ddd989d5 100644 --- a/ecstore/src/disk/local.rs +++ b/ecstore/src/disk/local.rs @@ -672,14 +672,8 @@ impl LocalDisk { let volume_dir = self.get_bucket_path(volume)?; - self.write_all_private( - volume, - format!("{path}/{STORAGE_FORMAT_FILE}").as_str(), - buf.into(), - true, - &volume_dir, - ) - .await?; + self.write_all_private(volume, format!("{path}/{STORAGE_FORMAT_FILE}").as_str(), buf.into(), true, &volume_dir) + .await?; Ok(()) } @@ -1399,8 +1393,7 @@ impl DiskAPI for LocalDisk { rename_all(&src_file_path, &dst_file_path, &dst_volume_dir).await?; - self.write_all(dst_volume, format!("{dst_path}.meta").as_str(), meta) - .await?; + self.write_all(dst_volume, format!("{dst_path}.meta").as_str(), meta).await?; if let Some(parent) = src_file_path.parent() { self.delete_file(&src_volume_dir, &parent.to_path_buf(), false, false).await?; @@ -2077,9 +2070,8 @@ impl DiskAPI for LocalDisk { // opts.undo_write && opts.old_data_dir.is_some_and(f) if let Some(old_data_dir) = opts.old_data_dir { if opts.undo_write { - let src_path = file_path.join(Path::new( - format!("{old_data_dir}{SLASH_SEPARATOR}{STORAGE_FORMAT_FILE_BACKUP}").as_str(), - )); + let src_path = + file_path.join(Path::new(format!("{old_data_dir}{SLASH_SEPARATOR}{STORAGE_FORMAT_FILE_BACKUP}").as_str())); let dst_path = file_path.join(Path::new(format!("{path}{SLASH_SEPARATOR}{STORAGE_FORMAT_FILE}").as_str())); return rename_all(src_path, dst_path, file_path).await; } diff --git a/ecstore/src/store_api.rs b/ecstore/src/store_api.rs index f16620b2..1ff2a79b 100644 --- a/ecstore/src/store_api.rs +++ b/ecstore/src/store_api.rs @@ -455,10 +455,7 @@ impl ObjectInfo { } if self.is_compressed() { - if let Some(size_str) = self - .user_defined - .get(&format!("{RESERVED_METADATA_PREFIX_LOWER}actual-size")) - { + if let Some(size_str) = self.user_defined.get(&format!("{RESERVED_METADATA_PREFIX_LOWER}actual-size")) { if !size_str.is_empty() { // Todo: deal with error let size = size_str.parse::().map_err(|e| std::io::Error::other(e.to_string()))?; diff --git a/iam/src/store/object.rs b/iam/src/store/object.rs index 00ab03cf..e623cd46 100644 --- a/iam/src/store/object.rs +++ b/iam/src/store/object.rs @@ -67,10 +67,7 @@ fn get_mapped_policy_path(name: &str, user_type: UserType, is_group: bool) -> St return path_join_buf(&[&IAM_CONFIG_POLICY_DB_GROUPS_PREFIX, format!("{name}.json").as_str()]); } match user_type { - UserType::Svc => path_join_buf(&[ - &IAM_CONFIG_POLICY_DB_SERVICE_ACCOUNTS_PREFIX, - format!("{name}.json").as_str(), - ]), + UserType::Svc => path_join_buf(&[&IAM_CONFIG_POLICY_DB_SERVICE_ACCOUNTS_PREFIX, format!("{name}.json").as_str()]), UserType::Sts => path_join_buf(&[&IAM_CONFIG_POLICY_DB_STS_USERS_PREFIX, format!("{name}.json").as_str()]), _ => path_join_buf(&[&IAM_CONFIG_POLICY_DB_USERS_PREFIX, format!("{name}.json").as_str()]), } diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 3df57b89..c7eab5ad 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -12,10 +12,10 @@ mod service; mod storage; use crate::auth::IAMAuth; -use crate::console::{init_console_cfg, CONSOLE_CONFIG}; +use crate::console::{CONSOLE_CONFIG, init_console_cfg}; // Ensure the correct path for parse_license is imported use crate::event::shutdown_event_notifier; -use crate::server::{wait_for_shutdown, ServiceState, ServiceStateManager, ShutdownSignal, SHUTDOWN_TIMEOUT}; +use crate::server::{SHUTDOWN_TIMEOUT, ServiceState, ServiceStateManager, ShutdownSignal, wait_for_shutdown}; use bytes::Bytes; use chrono::Datelike; use clap::Parser; @@ -23,6 +23,7 @@ use common::{ // error::{Error, Result}, globals::set_global_addr, }; +use ecstore::StorageAPI; use ecstore::bucket::metadata_sys::init_bucket_metadata_sys; use ecstore::cmd::bucket_replication::init_bucket_replication_pool; use ecstore::config as ecconfig; @@ -30,12 +31,11 @@ use ecstore::config::GLOBAL_ConfigSys; use ecstore::heal::background_heal_ops::init_auto_heal; use ecstore::rpc::make_server; use ecstore::store_api::BucketOptions; -use ecstore::StorageAPI; use ecstore::{ endpoints::EndpointServerPools, heal::data_scanner::init_data_scanner, set_global_endpoints, - store::{init_local_disks, ECStore}, + store::{ECStore, init_local_disks}, update_erasure_type, }; use ecstore::{global::set_global_rustfs_port, notification_sys::new_global_notification_sys}; @@ -50,7 +50,7 @@ use iam::init_iam_sys; use license::init_license; use protos::proto_gen::node_service::node_service_server::NodeServiceServer; use rustfs_config::{DEFAULT_ACCESS_KEY, DEFAULT_SECRET_KEY, RUSTFS_TLS_CERT, RUSTFS_TLS_KEY}; -use rustfs_obs::{init_obs, set_global_guard, SystemObserver}; +use rustfs_obs::{SystemObserver, init_obs, set_global_guard}; use rustfs_utils::net::parse_and_resolve_address; use rustls::ServerConfig; use s3s::{host::MultiDomain, service::S3ServiceBuilder}; @@ -62,12 +62,12 @@ use std::sync::Arc; use std::time::Duration; use tokio::net::TcpListener; #[cfg(unix)] -use tokio::signal::unix::{signal, SignalKind}; +use tokio::signal::unix::{SignalKind, signal}; use tokio_rustls::TlsAcceptor; -use tonic::{metadata::MetadataValue, Request, Status}; +use tonic::{Request, Status, metadata::MetadataValue}; use tower_http::cors::CorsLayer; use tower_http::trace::TraceLayer; -use tracing::{debug, error, info, instrument, warn, Span}; +use tracing::{Span, debug, error, info, instrument, warn}; const MI_B: usize = 1024 * 1024; diff --git a/s3select/query/src/sql/dialect.rs b/s3select/query/src/sql/dialect.rs index 289989d3..ec668715 100644 --- a/s3select/query/src/sql/dialect.rs +++ b/s3select/query/src/sql/dialect.rs @@ -236,10 +236,7 @@ mod tests { let unicode_letters = ['α', 'β', 'γ', 'Α', 'Β', 'Γ', '中', '文', '日', '本', 'ñ', 'ü', 'ç']; for ch in unicode_letters { - assert!( - dialect.is_identifier_start(ch), - "Unicode letter '{ch}' should be valid identifier start" - ); + assert!(dialect.is_identifier_start(ch), "Unicode letter '{ch}' should be valid identifier start"); assert!(dialect.is_identifier_part(ch), "Unicode letter '{ch}' should be valid identifier part"); } } @@ -254,10 +251,7 @@ mod tests { !dialect.is_identifier_start(digit), "ASCII digit '{digit}' should not be valid identifier start" ); - assert!( - dialect.is_identifier_part(digit), - "ASCII digit '{digit}' should be valid identifier part" - ); + assert!(dialect.is_identifier_part(digit), "ASCII digit '{digit}' should be valid identifier part"); } }