mirror of
https://github.com/rustfs/rustfs.git
synced 2026-01-17 01:30:33 +00:00
fix:Apply suggestions from clippy 1.88 (#20)
This commit is contained in:
@@ -87,7 +87,7 @@ pub fn streaming_sign_v4(
|
||||
headers.insert("X-Amz-Date", HeaderValue::from_str(&req_time.format(&format).unwrap()).expect("err"));
|
||||
|
||||
//req.content_length = 100;
|
||||
headers.insert("x-amz-decoded-content-length", format!("{:010}", data_len).parse().unwrap());
|
||||
headers.insert("x-amz-decoded-content-length", format!("{data_len:010}").parse().unwrap());
|
||||
|
||||
req
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn pre_sign_v2(
|
||||
let headers = req.headers_mut().expect("headers_mut err");
|
||||
let expires_str = headers.get("Expires");
|
||||
if expires_str.is_none() {
|
||||
headers.insert("Expires", format!("{:010}", epoch_expires).parse().unwrap());
|
||||
headers.insert("Expires", format!("{epoch_expires:010}").parse().unwrap());
|
||||
}
|
||||
|
||||
let string_to_sign = pre_string_to_sign_v2(&req, virtual_host);
|
||||
@@ -49,7 +49,7 @@ pub fn pre_sign_v2(
|
||||
query.insert("AWSAccessKeyId".to_string(), access_key_id.to_string());
|
||||
}
|
||||
|
||||
query.insert("Expires".to_string(), format!("{:010}", epoch_expires));
|
||||
query.insert("Expires".to_string(), format!("{epoch_expires:010}"));
|
||||
|
||||
let uri = req.uri_ref().unwrap().clone();
|
||||
let mut parts = req.uri_ref().unwrap().clone().into_parts();
|
||||
@@ -95,7 +95,7 @@ pub fn sign_v2(
|
||||
);
|
||||
}
|
||||
|
||||
let auth_header = format!("{} {}:", SIGN_V2_ALGORITHM, access_key_id);
|
||||
let auth_header = format!("{SIGN_V2_ALGORITHM} {access_key_id}:");
|
||||
let auth_header = format!("{}{}", auth_header, base64_encode(&hmac_sha1(secret_access_key, string_to_sign)));
|
||||
|
||||
headers.insert("Authorization", auth_header.parse().unwrap());
|
||||
|
||||
@@ -166,7 +166,7 @@ fn get_canonical_request(req: &request::Builder, ignored_headers: &HashMap<Strin
|
||||
query_params.sort_by(|a, b| a.0.cmp(&b.0));
|
||||
|
||||
// Build canonical query string
|
||||
let sorted_params: Vec<String> = query_params.iter().map(|(k, v)| format!("{}={}", k, v)).collect();
|
||||
let sorted_params: Vec<String> = query_params.iter().map(|(k, v)| format!("{k}={v}")).collect();
|
||||
|
||||
canonical_query_string = sorted_params.join("&");
|
||||
canonical_query_string = canonical_query_string.replace("+", "%20");
|
||||
@@ -219,7 +219,7 @@ pub fn pre_sign_v4(
|
||||
query.push(("X-Amz-Algorithm".to_string(), SIGN_V4_ALGORITHM.to_string()));
|
||||
let format = format_description!("[year][month][day]T[hour][minute][second]Z");
|
||||
query.push(("X-Amz-Date".to_string(), t.format(&format).unwrap().to_string()));
|
||||
query.push(("X-Amz-Expires".to_string(), format!("{:010}", expires)));
|
||||
query.push(("X-Amz-Expires".to_string(), format!("{expires:010}")));
|
||||
query.push(("X-Amz-SignedHeaders".to_string(), signed_headers));
|
||||
query.push(("X-Amz-Credential".to_string(), credential));
|
||||
if !session_token.is_empty() {
|
||||
@@ -300,7 +300,7 @@ fn sign_v4_inner(
|
||||
}
|
||||
|
||||
headers.insert("Content-Encoding", "aws-chunked".parse().unwrap());
|
||||
headers.insert("x-amz-decoded-content-length", format!("{:010}", content_len).parse().unwrap());
|
||||
headers.insert("x-amz-decoded-content-length", format!("{content_len:010}").parse().unwrap());
|
||||
}
|
||||
|
||||
if service_type == SERVICE_TYPE_STS {
|
||||
@@ -318,10 +318,7 @@ fn sign_v4_inner(
|
||||
|
||||
let headers = req.headers_mut().expect("err");
|
||||
|
||||
let auth = format!(
|
||||
"{} Credential={}, SignedHeaders={}, Signature={}",
|
||||
SIGN_V4_ALGORITHM, credential, signed_headers, signature
|
||||
);
|
||||
let auth = format!("{SIGN_V4_ALGORITHM} Credential={credential}, SignedHeaders={signed_headers}, Signature={signature}");
|
||||
headers.insert("Authorization", auth.parse().unwrap());
|
||||
|
||||
if !trailer.is_empty() {
|
||||
@@ -350,7 +347,7 @@ fn _unsigned_trailer(mut req: request::Builder, content_len: i64, trailer: Heade
|
||||
}
|
||||
|
||||
headers.insert("Content-Encoding", "aws-chunked".parse().unwrap());
|
||||
headers.insert("x-amz-decoded-content-length", format!("{:010}", content_len).parse().unwrap());
|
||||
headers.insert("x-amz-decoded-content-length", format!("{content_len:010}").parse().unwrap());
|
||||
|
||||
if !trailer.is_empty() {
|
||||
for (_, v) in &trailer {
|
||||
|
||||
@@ -91,7 +91,7 @@ pub async fn read_dir(path: impl AsRef<Path>, count: i32) -> std::io::Result<Vec
|
||||
if file_type.is_file() {
|
||||
volumes.push(name);
|
||||
} else if file_type.is_dir() {
|
||||
volumes.push(format!("{}{}", name, SLASH_SEPARATOR));
|
||||
volumes.push(format!("{name}{SLASH_SEPARATOR}"));
|
||||
}
|
||||
count -= 1;
|
||||
if count == 0 {
|
||||
|
||||
@@ -81,7 +81,7 @@ impl Operation for SetNotificationTarget {
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("failed to set target config: {}", e);
|
||||
S3Error::with_message(S3ErrorCode::InternalError, format!("failed to set target config: {}", e))
|
||||
S3Error::with_message(S3ErrorCode::InternalError, format!("failed to set target config: {e}"))
|
||||
})?;
|
||||
|
||||
let mut header = HeaderMap::new();
|
||||
@@ -124,7 +124,7 @@ impl Operation for ListNotificationTargets {
|
||||
|
||||
// 4. Serialize and return the result
|
||||
let data = serde_json::to_vec(&data_target_arn_list)
|
||||
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("failed to serialize targets: {}", e)))?;
|
||||
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("failed to serialize targets: {e}")))?;
|
||||
debug!("ListNotificationTargets call end, response data length: {}", data.len(),);
|
||||
let mut header = HeaderMap::new();
|
||||
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||
@@ -159,7 +159,7 @@ impl Operation for RemoveNotificationTarget {
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("failed to remove target config: {}", e);
|
||||
S3Error::with_message(S3ErrorCode::InternalError, format!("failed to remove target config: {}", e))
|
||||
S3Error::with_message(S3ErrorCode::InternalError, format!("failed to remove target config: {e}"))
|
||||
})?;
|
||||
|
||||
let mut header = HeaderMap::new();
|
||||
@@ -204,7 +204,7 @@ impl Operation for SetBucketNotification {
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("failed to load bucket notification config: {}", e);
|
||||
S3Error::with_message(S3ErrorCode::InternalError, format!("failed to load bucket notification config: {}", e))
|
||||
S3Error::with_message(S3ErrorCode::InternalError, format!("failed to load bucket notification config: {e}"))
|
||||
})?;
|
||||
|
||||
let mut header = HeaderMap::new();
|
||||
@@ -241,7 +241,7 @@ impl Operation for GetBucketNotification {
|
||||
};
|
||||
|
||||
let data = serde_json::to_vec(&response)
|
||||
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("failed to serialize rules: {}", e)))?;
|
||||
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("failed to serialize rules: {e}")))?;
|
||||
|
||||
let mut header = HeaderMap::new();
|
||||
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||
|
||||
@@ -145,7 +145,7 @@ impl Operation for AddTier {
|
||||
warn!("tier_config_mgr add failed, e: {:?}", err);
|
||||
return Err(S3Error::with_message(
|
||||
S3ErrorCode::Custom("TierAddFailed".into()),
|
||||
format!("tier add failed. {}", err),
|
||||
format!("tier add failed. {err}"),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -212,7 +212,7 @@ impl Operation for EditTier {
|
||||
warn!("tier_config_mgr edit failed, e: {:?}", err);
|
||||
return Err(S3Error::with_message(
|
||||
S3ErrorCode::Custom("TierEditFailed".into()),
|
||||
format!("tier edit failed. {}", err),
|
||||
format!("tier edit failed. {err}"),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -307,7 +307,7 @@ impl Operation for RemoveTier {
|
||||
warn!("tier_config_mgr remove failed, e: {:?}", err);
|
||||
return Err(S3Error::with_message(
|
||||
S3ErrorCode::Custom("TierRemoveFailed".into()),
|
||||
format!("tier remove failed. {}", err),
|
||||
format!("tier remove failed. {err}"),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -434,7 +434,7 @@ impl Operation for ClearTier {
|
||||
warn!("tier_config_mgr clear failed, e: {:?}", err);
|
||||
return Err(S3Error::with_message(
|
||||
S3ErrorCode::Custom("TierClearFailed".into()),
|
||||
format!("tier clear failed. {}", err),
|
||||
format!("tier clear failed. {err}"),
|
||||
));
|
||||
}
|
||||
if let Err(e) = tier_config_mgr.save().await {
|
||||
|
||||
@@ -104,8 +104,7 @@ impl VersionChecker {
|
||||
let error_text = response.text().await.unwrap_or_default();
|
||||
error!("Version check request failed, status code: {}, response: {}", status, error_text);
|
||||
return Err(UpdateCheckError::InvalidResponse(format!(
|
||||
"HTTP status code: {}, response: {}",
|
||||
status, error_text
|
||||
"HTTP status code: {status}, response: {error_text}"
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -117,8 +116,7 @@ impl VersionChecker {
|
||||
let error_text = String::from_utf8_lossy(&response_bytes);
|
||||
error!("Version check request failed, response: {}", e);
|
||||
return Err(UpdateCheckError::InvalidResponse(format!(
|
||||
"JSON parsing failed: {}, response: {}",
|
||||
e, error_text
|
||||
"JSON parsing failed: {e}, response: {error_text}"
|
||||
)));
|
||||
}
|
||||
};
|
||||
@@ -196,7 +194,7 @@ impl VersionChecker {
|
||||
let parts: Vec<&str> = version.split('.').collect();
|
||||
|
||||
if parts.len() < 3 {
|
||||
return Err(UpdateCheckError::VersionParseError(format!("Invalid version format: {}", version)));
|
||||
return Err(UpdateCheckError::VersionParseError(format!("Invalid version format: {version}")));
|
||||
}
|
||||
|
||||
let major = parts[0]
|
||||
@@ -292,7 +290,7 @@ mod tests {
|
||||
async fn test_get_current_version() {
|
||||
let version = get_current_version();
|
||||
assert!(!version.is_empty());
|
||||
println!("Current version: {}", version);
|
||||
println!("Current version: {version}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -341,7 +339,7 @@ mod tests {
|
||||
assert_eq!(cloned_result.check_time, result.check_time);
|
||||
|
||||
// Test Debug functionality (should not panic)
|
||||
let debug_output = format!("{:?}", result);
|
||||
let debug_output = format!("{result:?}");
|
||||
assert!(debug_output.contains("UpdateCheckResult"));
|
||||
assert!(debug_output.contains("1.1.0"));
|
||||
assert!(debug_output.contains("1.2.0"));
|
||||
@@ -403,7 +401,7 @@ mod tests {
|
||||
assert_eq!(cloned_info.download_url, version_info.download_url);
|
||||
|
||||
// Test Debug functionality
|
||||
let debug_output = format!("{:?}", version_info);
|
||||
let debug_output = format!("{version_info:?}");
|
||||
assert!(debug_output.contains("VersionInfo"));
|
||||
assert!(debug_output.contains("2.0.0"));
|
||||
|
||||
@@ -422,7 +420,7 @@ mod tests {
|
||||
|
||||
// Test JSON serialization/deserialization
|
||||
let json_string = serde_json::to_string(&version_info).unwrap();
|
||||
println!("json_string: {}", json_string);
|
||||
println!("json_string: {json_string}");
|
||||
assert!(json_string.contains("2.0.0"));
|
||||
assert!(json_string.contains("Major release"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user