fix clippy

This commit is contained in:
weisd
2025-06-25 11:13:29 +08:00
parent 280d14997a
commit 61e600b9ba
15 changed files with 127 additions and 117 deletions
+38 -16
View File
@@ -1,20 +1,18 @@
use std::str::from_utf8;
#![allow(unused_variables, unused_mut, unused_must_use)]
use http::{HeaderMap, StatusCode};
//use iam::get_global_action_cred;
use matchit::Params;
use s3s::{Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, header::CONTENT_TYPE, s3_error};
use serde::Deserialize;
use serde_urlencoded::from_bytes;
use tracing::{debug, info, warn};
use tracing::{debug, warn};
use crate::{
admin::{router::Operation, utils::has_space_be},
admin::router::Operation,
auth::{check_key_valid, get_session_token},
};
use crypto::{decrypt_data, encrypt_data};
use ecstore::{
client::admin_handler_utils::AdminError,
config::storageclass,
global::GLOBAL_TierConfigMgr,
tier::{
@@ -28,13 +26,30 @@ use ecstore::{
},
};
#[derive(Debug, Deserialize, Default)]
#[derive(Debug, Clone, serde::Deserialize, Default)]
pub struct AddTierQuery {
#[serde(rename = "accessKey")]
#[allow(dead_code)]
pub access_key: Option<String>,
#[allow(dead_code)]
pub status: Option<String>,
#[serde(rename = "secretKey")]
#[allow(dead_code)]
pub secret_key: Option<String>,
#[serde(rename = "serviceName")]
#[allow(dead_code)]
pub service_name: Option<String>,
#[serde(rename = "sessionToken")]
#[allow(dead_code)]
pub session_token: Option<String>,
pub tier: Option<String>,
pub force: String,
#[serde(rename = "tierName")]
#[allow(dead_code)]
pub tier_name: Option<String>,
#[serde(rename = "tierType")]
#[allow(dead_code)]
pub tier_type: Option<String>,
pub force: Option<String>,
}
pub struct AddTier {}
@@ -86,9 +101,12 @@ impl Operation for AddTier {
debug!("add tier args {:?}", args);
let mut force: bool = false;
let force_str = query.force;
if force_str != "" {
force = force_str.parse().unwrap();
let force_str = query.force.clone().unwrap_or_default();
if !force_str.is_empty() {
force = force_str.parse().map_err(|e| {
warn!("parse force failed, e: {:?}", e);
s3_error!(InvalidRequest, "parse force failed")
})?;
}
match args.name.as_str() {
storageclass::STANDARD | storageclass::RRS => {
@@ -221,9 +239,10 @@ impl Operation for EditTier {
}
}
#[derive(Debug, Deserialize, Default)]
#[derive(Debug, Clone, serde::Deserialize, Default)]
pub struct BucketQuery {
#[serde(rename = "bucket")]
#[allow(dead_code)]
pub bucket: String,
}
pub struct ListTiers {}
@@ -281,9 +300,12 @@ impl Operation for RemoveTier {
// .ok_or_else(|| S3Error::with_message(S3ErrorCode::InternalError, "get_global_action_cred failed"))?;
let mut force: bool = false;
let force_str = query.force;
if force_str != "" {
force = force_str.parse().unwrap();
let force_str = query.force.clone().unwrap_or_default();
if !force_str.is_empty() {
force = force_str.parse().map_err(|e| {
warn!("parse force failed, e: {:?}", e);
s3_error!(InvalidRequest, "parse force failed")
})?;
}
let tier_name = params.get("tiername").map(|s| s.to_string()).unwrap_or_default();
@@ -346,7 +368,7 @@ impl Operation for VerifyTier {
// .ok_or_else(|| S3Error::with_message(S3ErrorCode::InternalError, "get_global_action_cred failed"))?;
let mut tier_config_mgr = GLOBAL_TierConfigMgr.write().await;
tier_config_mgr.verify(&query.tier.unwrap());
tier_config_mgr.verify(&query.tier.unwrap()).await;
let mut header = HeaderMap::new();
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
+5 -15
View File
@@ -18,7 +18,7 @@ use chrono::Utc;
use datafusion::arrow::csv::WriterBuilder as CsvWriterBuilder;
use datafusion::arrow::json::WriterBuilder as JsonWriterBuilder;
use datafusion::arrow::json::writer::JsonArray;
use ecstore::bucket::error::BucketMetadataError;
use ecstore::bucket::metadata::BUCKET_LIFECYCLE_CONFIG;
use ecstore::bucket::metadata::BUCKET_NOTIFICATION_CONFIG;
use ecstore::bucket::metadata::BUCKET_POLICY_CONFIG;
@@ -56,8 +56,7 @@ use ecstore::store_api::PutObjReader;
use ecstore::store_api::StorageAPI;
// use ecstore::store_api::RESERVED_METADATA_PREFIX;
use ecstore::bucket::lifecycle::bucket_lifecycle_ops::validate_transition_tier;
use futures::pin_mut;
use futures::{Stream, StreamExt};
use futures::StreamExt;
use http::HeaderMap;
use lazy_static::lazy_static;
use policy::auth;
@@ -102,10 +101,7 @@ use tracing::info;
use tracing::warn;
use uuid::Uuid;
use ecstore::bucket::{
lifecycle::{bucket_lifecycle_ops::ERR_INVALID_STORAGECLASS, lifecycle::Lifecycle},
object_lock::objectlock_sys::BucketObjectLockSys,
};
use ecstore::bucket::lifecycle::lifecycle::Lifecycle;
macro_rules! try_ {
($result:expr) => {
@@ -1733,18 +1729,12 @@ impl S3 for FS {
if let Err(err) = input_cfg.validate(&rcfg).await {
//return Err(S3Error::with_message(S3ErrorCode::Custom("BucketLockValidateFailed".into()), "bucket lock validate failed."));
return Err(S3Error::with_message(
S3ErrorCode::Custom("ValidateFailed".into()),
format!("{}", err.to_string()),
));
return Err(S3Error::with_message(S3ErrorCode::Custom("ValidateFailed".into()), err.to_string()));
}
if let Err(err) = validate_transition_tier(&input_cfg).await {
//warn!("lifecycle_configuration add failed, err: {:?}", err);
return Err(S3Error::with_message(
S3ErrorCode::Custom("CustomError".into()),
format!("{}", err.to_string()),
));
return Err(S3Error::with_message(S3ErrorCode::Custom("CustomError".into()), err.to_string()));
}
let data = try_!(serialize(&input_cfg));