mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-11 07:36:53 +00:00
chore(lint): clippy rules redundant_clone (#2554)
This commit is contained in:
@@ -601,7 +601,7 @@ impl Operation for ListAuditTargets {
|
||||
Ok(Ok(true)) => "online",
|
||||
_ => "offline",
|
||||
};
|
||||
((target.id().id.clone(), target.id().name.to_string()), status.to_string())
|
||||
((target.id().id, target.id().name), status.to_string())
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -523,7 +523,7 @@ impl Operation for ListNotificationTargets {
|
||||
Ok(Ok(true)) => "online",
|
||||
_ => "offline",
|
||||
};
|
||||
((target.id().id.clone(), target.id().name.to_string()), status.to_string())
|
||||
((target.id().id, target.id().name), status.to_string())
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -288,7 +288,7 @@ impl Operation for GetOidcConfigHandler {
|
||||
groups_claim: provider.config.groups_claim.clone(),
|
||||
roles_claim: provider.config.roles_claim.clone(),
|
||||
email_claim: provider.config.email_claim.clone(),
|
||||
username_claim: provider.config.username_claim.clone(),
|
||||
username_claim: provider.config.username_claim,
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
@@ -193,9 +193,7 @@ impl Operation for AddServiceAccount {
|
||||
return Err(s3_error!(InvalidRequest, "access key has spaces"));
|
||||
}
|
||||
|
||||
create_req
|
||||
.validate()
|
||||
.map_err(|e| S3Error::with_message(InvalidRequest, e.to_string()))?;
|
||||
create_req.validate().map_err(|e| S3Error::with_message(InvalidRequest, e))?;
|
||||
|
||||
let session_policy = if let Some(policy) = &create_req.policy {
|
||||
let policy_bytes =
|
||||
@@ -528,9 +526,7 @@ impl Operation for UpdateServiceAccount {
|
||||
let update_req: UpdateServiceAccountReq =
|
||||
serde_json::from_slice(&body[..]).map_err(|e| s3_error!(InvalidRequest, "unmarshal body failed, e: {:?}", e))?;
|
||||
|
||||
update_req
|
||||
.validate()
|
||||
.map_err(|e| S3Error::with_message(InvalidRequest, e.to_string()))?;
|
||||
update_req.validate().map_err(|e| S3Error::with_message(InvalidRequest, e))?;
|
||||
|
||||
let (cred, owner) =
|
||||
check_key_valid(get_session_token(&req.uri, &req.headers).unwrap_or_default(), &input_cred.access_key).await?;
|
||||
|
||||
@@ -265,7 +265,7 @@ impl Operation for AddTier {
|
||||
"tier connect error!",
|
||||
))
|
||||
} else if err.code == ERR_TIER_INVALID_CREDENTIALS.code {
|
||||
Err(S3Error::with_message(S3ErrorCode::Custom(err.code.clone().into()), err.message.clone()))
|
||||
Err(S3Error::with_message(S3ErrorCode::Custom(err.code.clone().into()), err.message))
|
||||
} else {
|
||||
warn!("tier_config_mgr add failed, e: {:?}", err);
|
||||
Err(S3Error::with_message(
|
||||
|
||||
@@ -364,7 +364,7 @@ mod deadlock_request_guard_tests {
|
||||
assert_eq!(detector.tracked_count(), 1);
|
||||
|
||||
{
|
||||
let _guard = DeadlockRequestGuard::new(Arc::clone(&detector), request_id.clone());
|
||||
let _guard = DeadlockRequestGuard::new(Arc::clone(&detector), request_id);
|
||||
// `_guard` is dropped at the end of this scope, which should unregister the request.
|
||||
}
|
||||
|
||||
@@ -618,10 +618,10 @@ fn apply_put_request_metadata(
|
||||
storage_class: Option<StorageClass>,
|
||||
) -> S3Result<()> {
|
||||
if let Some(cache_control) = cache_control {
|
||||
metadata.insert("cache-control".to_string(), cache_control.to_string());
|
||||
metadata.insert("cache-control".to_string(), cache_control);
|
||||
}
|
||||
if let Some(content_disposition) = content_disposition {
|
||||
metadata.insert("content-disposition".to_string(), content_disposition.to_string());
|
||||
metadata.insert("content-disposition".to_string(), content_disposition);
|
||||
}
|
||||
if let Some(content_encoding) = content_encoding
|
||||
&& let Some(normalized_content_encoding) = normalize_content_encoding_for_storage(&content_encoding)
|
||||
@@ -629,10 +629,10 @@ fn apply_put_request_metadata(
|
||||
metadata.insert("content-encoding".to_string(), normalized_content_encoding);
|
||||
}
|
||||
if let Some(content_language) = content_language {
|
||||
metadata.insert("content-language".to_string(), content_language.to_string());
|
||||
metadata.insert("content-language".to_string(), content_language);
|
||||
}
|
||||
if let Some(content_type) = content_type {
|
||||
metadata.insert("content-type".to_string(), content_type.to_string());
|
||||
metadata.insert("content-type".to_string(), content_type);
|
||||
}
|
||||
if let Some(expires) = expires {
|
||||
let mut formatted = Vec::new();
|
||||
@@ -642,10 +642,10 @@ fn apply_put_request_metadata(
|
||||
metadata.insert("expires".to_string(), String::from_utf8_lossy(&formatted).into_owned());
|
||||
}
|
||||
if let Some(website_redirect_location) = website_redirect_location {
|
||||
metadata.insert(AMZ_WEBSITE_REDIRECT_LOCATION.to_string(), website_redirect_location.to_string());
|
||||
metadata.insert(AMZ_WEBSITE_REDIRECT_LOCATION.to_string(), website_redirect_location);
|
||||
}
|
||||
if let Some(tags) = tagging {
|
||||
metadata.insert(AMZ_OBJECT_TAGGING.to_owned(), tags.to_string());
|
||||
metadata.insert(AMZ_OBJECT_TAGGING.to_owned(), tags);
|
||||
}
|
||||
if let Some(storage_class) = storage_class {
|
||||
metadata.insert(AMZ_STORAGE_CLASS.to_string(), storage_class.as_str().to_string());
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ impl S3Auth for IAMAuth {
|
||||
Ok((Some(id), _valid)) => {
|
||||
// Return secret key for signature verification regardless of user status.
|
||||
// Authorization will be checked separately in the authorization phase.
|
||||
return Ok(SecretKey::from(id.credentials.secret_key.clone()));
|
||||
return Ok(SecretKey::from(id.credentials.secret_key));
|
||||
}
|
||||
Ok((None, _)) => {
|
||||
warn!("get_secret_key failed: no such user, access_key: {access_key}");
|
||||
|
||||
@@ -549,7 +549,7 @@ fn collect_config_info_json() -> ConfigInfoJson {
|
||||
let profile = config.workload_profile();
|
||||
let buffer_config = profile.config();
|
||||
Some(WorkloadProfileJson {
|
||||
name: config.workload_name().to_string(),
|
||||
name: config.workload_name(),
|
||||
buffer_min_size: buffer_config.min_size,
|
||||
buffer_max_size: buffer_config.max_size,
|
||||
default_unknown: buffer_config.default_unknown,
|
||||
|
||||
@@ -530,7 +530,7 @@ mod tests {
|
||||
thresholds: vec![(MI_B as i64, 64 * KI_B), (i64::MAX, 256 * KI_B)],
|
||||
};
|
||||
|
||||
let profile = WorkloadProfile::Custom(custom_config.clone());
|
||||
let profile = WorkloadProfile::Custom(custom_config);
|
||||
let config = profile.config();
|
||||
|
||||
assert_eq!(config.calculate_buffer_size(512 * KI_B as i64), 64 * KI_B);
|
||||
@@ -619,7 +619,7 @@ mod tests {
|
||||
};
|
||||
let custom2 = custom1.clone();
|
||||
|
||||
assert_eq!(WorkloadProfile::Custom(custom1.clone()), WorkloadProfile::Custom(custom2));
|
||||
assert_eq!(WorkloadProfile::Custom(custom1), WorkloadProfile::Custom(custom2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -645,7 +645,7 @@ mod tests {
|
||||
mime_patterns: vec!["text/*".to_string()],
|
||||
min_size: 0,
|
||||
};
|
||||
let predicate = CompressionPredicate::new(config_disabled.clone());
|
||||
let predicate = CompressionPredicate::new(config_disabled);
|
||||
assert!(!predicate.config.enabled);
|
||||
|
||||
let config_enabled = CompressionConfig {
|
||||
@@ -654,7 +654,7 @@ mod tests {
|
||||
mime_patterns: vec!["text/*".to_string(), "application/json".to_string()],
|
||||
min_size: 1000,
|
||||
};
|
||||
let predicate = CompressionPredicate::new(config_enabled.clone());
|
||||
let predicate = CompressionPredicate::new(config_enabled);
|
||||
assert!(predicate.config.enabled);
|
||||
assert_eq!(predicate.config.extensions.len(), 2);
|
||||
assert_eq!(predicate.config.mime_patterns.len(), 2);
|
||||
|
||||
@@ -224,7 +224,7 @@ pub async fn start_http_server(
|
||||
let secret_key = config.secret_key.clone();
|
||||
|
||||
b.set_auth(IAMAuth::new(access_key, secret_key));
|
||||
b.set_access(store.clone());
|
||||
b.set_access(store);
|
||||
b.set_route(admin::make_admin_route(config.console_enable)?);
|
||||
|
||||
// Virtual-hosted-style requests are only set up for S3 API when server domains are configured and console is disabled
|
||||
|
||||
@@ -119,7 +119,7 @@ impl ConcurrencyManager {
|
||||
|
||||
// Initialize metrics collector for I/O latency tracking
|
||||
// Keep 1000 samples for P95/P99 calculation
|
||||
let metrics_collector = Arc::new(MetricsCollector::new(performance_metrics.clone(), 1000));
|
||||
let metrics_collector = Arc::new(MetricsCollector::new(performance_metrics, 1000));
|
||||
|
||||
// Build priority queue config
|
||||
let queue_config = IoPriorityQueueConfig {
|
||||
|
||||
@@ -1021,7 +1021,7 @@ mod tests {
|
||||
"if-modified-since",
|
||||
HeaderValue::from_str(&valid_mod_time.format(&RFC1123).unwrap()).unwrap(),
|
||||
);
|
||||
let info14 = info3.clone();
|
||||
let info14 = info3;
|
||||
assert!(check_preconditions(&headers14, &info14).is_ok());
|
||||
|
||||
// [15] If-Match with no ETag → PreconditionFailed
|
||||
|
||||
@@ -60,7 +60,7 @@ where
|
||||
{
|
||||
match request_context {
|
||||
Some(ctx) => {
|
||||
let request_id = ctx.request_id.clone();
|
||||
let request_id = ctx.request_id;
|
||||
let span = info_span!("background-task", request_id = %request_id);
|
||||
spawn_background(Instrument::instrument(fut, span));
|
||||
}
|
||||
@@ -136,7 +136,7 @@ impl OperationHelper {
|
||||
|
||||
let event_object = ObjectInfo {
|
||||
bucket: bucket.clone(),
|
||||
name: object_key.clone(),
|
||||
name: object_key,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
||||
@@ -934,7 +934,7 @@ async fn apply_ssec_encryption_material(
|
||||
) -> Result<EncryptionMaterial, ApiError> {
|
||||
let params = SsecParams {
|
||||
algorithm,
|
||||
key: sse_key.to_string(),
|
||||
key: sse_key,
|
||||
key_md5: sse_key_md5,
|
||||
};
|
||||
|
||||
@@ -1058,7 +1058,7 @@ async fn apply_managed_encryption_material(
|
||||
}
|
||||
|
||||
// Determine KMS key ID to use for internal key wrapping.
|
||||
let mut kms_key_candidate = kms_key_id.clone().map(|s| s.to_string());
|
||||
let mut kms_key_candidate = kms_key_id.clone();
|
||||
if kms_key_candidate.is_none() {
|
||||
// Try to get default key from KMS service (if available)
|
||||
if let Some(service) = get_global_encryption_service().await {
|
||||
|
||||
@@ -206,7 +206,7 @@ mod tests {
|
||||
let result = UpdateCheckResult {
|
||||
update_available: true,
|
||||
current_version: "1.1.0".to_string(),
|
||||
latest_version: Some(version_info.clone()),
|
||||
latest_version: Some(version_info),
|
||||
check_time: check_time.clone(),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user