mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-12 08:06:54 +00:00
fix clippy
This commit is contained in:
@@ -53,8 +53,7 @@ impl From<Error> for BucketMetadataError {
|
||||
|
||||
impl From<std::io::Error> for BucketMetadataError {
|
||||
fn from(e: std::io::Error) -> Self {
|
||||
e.downcast::<BucketMetadataError>()
|
||||
.unwrap_or_else(|e| BucketMetadataError::other(e))
|
||||
e.downcast::<BucketMetadataError>().unwrap_or_else(BucketMetadataError::other)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -226,9 +226,9 @@ impl From<DiskError> for StorageError {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<DiskError> for StorageError {
|
||||
fn into(self) -> DiskError {
|
||||
match self {
|
||||
impl From<StorageError> for DiskError {
|
||||
fn from(val: StorageError) -> Self {
|
||||
match val {
|
||||
StorageError::Io(io_error) => io_error.into(),
|
||||
StorageError::Unexpected => DiskError::Unexpected,
|
||||
StorageError::FileNotFound => DiskError::FileNotFound,
|
||||
@@ -250,7 +250,7 @@ impl Into<DiskError> for StorageError {
|
||||
StorageError::VolumeNotFound => DiskError::VolumeNotFound,
|
||||
StorageError::VolumeExists => DiskError::VolumeExists,
|
||||
StorageError::FileNameTooLong => DiskError::FileNameTooLong,
|
||||
_ => DiskError::other(self),
|
||||
_ => DiskError::other(val),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -292,9 +292,9 @@ impl From<rustfs_filemeta::Error> for StorageError {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<rustfs_filemeta::Error> for StorageError {
|
||||
fn into(self) -> rustfs_filemeta::Error {
|
||||
match self {
|
||||
impl From<StorageError> for rustfs_filemeta::Error {
|
||||
fn from(val: StorageError) -> Self {
|
||||
match val {
|
||||
StorageError::Unexpected => rustfs_filemeta::Error::Unexpected,
|
||||
StorageError::FileNotFound => rustfs_filemeta::Error::FileNotFound,
|
||||
StorageError::FileVersionNotFound => rustfs_filemeta::Error::FileVersionNotFound,
|
||||
@@ -303,7 +303,7 @@ impl Into<rustfs_filemeta::Error> for StorageError {
|
||||
StorageError::MethodNotAllowed => rustfs_filemeta::Error::MethodNotAllowed,
|
||||
StorageError::VolumeNotFound => rustfs_filemeta::Error::VolumeNotFound,
|
||||
StorageError::Io(io_error) => io_error.into(),
|
||||
_ => rustfs_filemeta::Error::other(self),
|
||||
_ => rustfs_filemeta::Error::other(val),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -372,7 +372,7 @@ impl Clone for StorageError {
|
||||
StorageError::DecommissionNotStarted => StorageError::DecommissionNotStarted,
|
||||
StorageError::DecommissionAlreadyRunning => StorageError::DecommissionAlreadyRunning,
|
||||
StorageError::DoneForNow => StorageError::DoneForNow,
|
||||
StorageError::InvalidPart(a, b, c) => StorageError::InvalidPart(a.clone(), b.clone(), c.clone()),
|
||||
StorageError::InvalidPart(a, b, c) => StorageError::InvalidPart(*a, b.clone(), c.clone()),
|
||||
StorageError::ErasureReadQuorum => StorageError::ErasureReadQuorum,
|
||||
StorageError::ErasureWriteQuorum => StorageError::ErasureWriteQuorum,
|
||||
StorageError::NotFirstDisk => StorageError::NotFirstDisk,
|
||||
@@ -717,7 +717,7 @@ pub fn to_object_err(err: Error, params: Vec<&str>) -> Error {
|
||||
let bucket = params.first().cloned().unwrap_or_default().to_owned();
|
||||
let object = params.get(1).cloned().map(decode_dir_object).unwrap_or_default();
|
||||
|
||||
return StorageError::PrefixAccessDenied(bucket, object);
|
||||
StorageError::PrefixAccessDenied(bucket, object)
|
||||
}
|
||||
|
||||
_ => err,
|
||||
|
||||
+1
-1
@@ -771,7 +771,7 @@ pub async fn heal_bucket_local(bucket: &str, opts: &HealOpts) -> Result<HealResu
|
||||
let bucket = bucket.to_string();
|
||||
let bs_clone = before_state.clone();
|
||||
let as_clone = after_state.clone();
|
||||
let errs_clone = errs.iter().map(|e| e.clone()).collect::<Vec<_>>();
|
||||
let errs_clone = errs.to_vec();
|
||||
futures.push(async move {
|
||||
if bs_clone.read().await[idx] == DRIVE_STATE_MISSING {
|
||||
info!("bucket not find, will recreate");
|
||||
|
||||
@@ -500,7 +500,7 @@ impl ECStore {
|
||||
if get_global_endpoints()
|
||||
.as_ref()
|
||||
.get(idx)
|
||||
.is_none_or(|v| v.endpoints.as_ref().first().map_or(true, |e| e.is_local))
|
||||
.is_none_or(|v| v.endpoints.as_ref().first().is_none_or(|e| e.is_local))
|
||||
{
|
||||
warn!("start_rebalance: pool {} is not local, skipping", idx);
|
||||
continue;
|
||||
|
||||
+13
-18
@@ -2828,22 +2828,17 @@ impl SetDisks {
|
||||
return Ok((result, None));
|
||||
}
|
||||
for (index, (err, disk)) in errs.iter().zip(disks.iter()).enumerate() {
|
||||
if let (Some(err), Some(disk)) = (err, disk) {
|
||||
match err {
|
||||
DiskError::VolumeNotFound | DiskError::FileNotFound => {
|
||||
let vol_path = Path::new(bucket).join(object);
|
||||
let drive_state = match disk.make_volume(vol_path.to_str().unwrap()).await {
|
||||
Ok(_) => DRIVE_STATE_OK,
|
||||
Err(merr) => match merr {
|
||||
DiskError::VolumeExists => DRIVE_STATE_OK,
|
||||
DiskError::DiskNotFound => DRIVE_STATE_OFFLINE,
|
||||
_ => DRIVE_STATE_CORRUPT,
|
||||
},
|
||||
};
|
||||
result.after.drives[index].state = drive_state.to_string();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if let (Some(DiskError::VolumeNotFound | DiskError::FileNotFound), Some(disk)) = (err, disk) {
|
||||
let vol_path = Path::new(bucket).join(object);
|
||||
let drive_state = match disk.make_volume(vol_path.to_str().unwrap()).await {
|
||||
Ok(_) => DRIVE_STATE_OK,
|
||||
Err(merr) => match merr {
|
||||
DiskError::VolumeExists => DRIVE_STATE_OK,
|
||||
DiskError::DiskNotFound => DRIVE_STATE_OFFLINE,
|
||||
_ => DRIVE_STATE_CORRUPT,
|
||||
},
|
||||
};
|
||||
result.after.drives[index].state = drive_state.to_string();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5563,7 +5558,7 @@ async fn disks_with_all_parts(
|
||||
if index < vec.len() {
|
||||
if verify_err.is_some() {
|
||||
info!("verify_err");
|
||||
vec[index] = conv_part_err_to_int(&verify_err.as_ref().map(|e| e.clone().into()));
|
||||
vec[index] = conv_part_err_to_int(&verify_err.clone());
|
||||
} else {
|
||||
info!("verify_resp, verify_resp.results {}", verify_resp.results[p]);
|
||||
vec[index] = verify_resp.results[p];
|
||||
@@ -5620,7 +5615,7 @@ pub fn should_heal_object_on_disk(
|
||||
}
|
||||
}
|
||||
}
|
||||
(false, err.as_ref().map(|e| e.clone()))
|
||||
(false, err.clone())
|
||||
}
|
||||
|
||||
async fn get_disks_info(disks: &[Option<DiskStore>], eps: &[Endpoint]) -> Vec<madmin::Disk> {
|
||||
|
||||
@@ -1319,7 +1319,7 @@ impl StorageAPI for ECStore {
|
||||
async fn make_bucket(&self, bucket: &str, opts: &MakeBucketOptions) -> Result<()> {
|
||||
if !is_meta_bucketname(bucket) {
|
||||
if let Err(err) = check_valid_bucket_name_strict(bucket) {
|
||||
return Err(StorageError::BucketNameInvalid(err.to_string()).into());
|
||||
return Err(StorageError::BucketNameInvalid(err.to_string()));
|
||||
}
|
||||
|
||||
// TODO: nslock
|
||||
@@ -1390,11 +1390,11 @@ impl StorageAPI for ECStore {
|
||||
#[tracing::instrument(skip(self))]
|
||||
async fn delete_bucket(&self, bucket: &str, opts: &DeleteBucketOptions) -> Result<()> {
|
||||
if is_meta_bucketname(bucket) {
|
||||
return Err(StorageError::BucketNameInvalid(bucket.to_string()).into());
|
||||
return Err(StorageError::BucketNameInvalid(bucket.to_string()));
|
||||
}
|
||||
|
||||
if let Err(err) = check_valid_bucket_name(bucket) {
|
||||
return Err(StorageError::BucketNameInvalid(err.to_string()).into());
|
||||
return Err(StorageError::BucketNameInvalid(err.to_string()));
|
||||
}
|
||||
|
||||
// TODO: nslock
|
||||
@@ -2186,7 +2186,7 @@ impl StorageAPI for ECStore {
|
||||
for (index, err) in errs.iter().enumerate() {
|
||||
match err {
|
||||
Some(err) => {
|
||||
if is_err_object_not_found(&err) || is_err_version_not_found(&err) {
|
||||
if is_err_object_not_found(err) || is_err_version_not_found(err) {
|
||||
continue;
|
||||
}
|
||||
return Ok((ress.remove(index), Some(err.clone())));
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
use crate::StorageAPI;
|
||||
use crate::bucket::metadata_sys::get_versioning_config;
|
||||
use crate::bucket::versioning::VersioningApi;
|
||||
use crate::cache_value::metacache_set::{list_path_raw, ListPathRawOptions};
|
||||
use crate::cache_value::metacache_set::{ListPathRawOptions, list_path_raw};
|
||||
use crate::disk::error::DiskError;
|
||||
use crate::disk::{DiskInfo, DiskStore};
|
||||
use crate::error::{
|
||||
is_all_not_found, is_all_volume_not_found, is_err_bucket_not_found, to_object_err, Error, Result, StorageError,
|
||||
Error, Result, StorageError, is_all_not_found, is_all_volume_not_found, is_err_bucket_not_found, to_object_err,
|
||||
};
|
||||
use crate::peer::is_reserved_or_invalid_bucket;
|
||||
use crate::set_disk::SetDisks;
|
||||
use crate::store::check_list_objs_args;
|
||||
use crate::store_api::{ListObjectVersionsInfo, ListObjectsInfo, ObjectInfo, ObjectOptions};
|
||||
use crate::utils::path::{self, base_dir_from_prefix, SLASH_SEPARATOR};
|
||||
use crate::StorageAPI;
|
||||
use crate::utils::path::{self, SLASH_SEPARATOR, base_dir_from_prefix};
|
||||
use crate::{store::ECStore, store_api::ListObjectsV2Info};
|
||||
use futures::future::join_all;
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::thread_rng;
|
||||
use rustfs_filemeta::{
|
||||
merge_file_meta_versions, FileInfo, MetaCacheEntries, MetaCacheEntriesSorted, MetaCacheEntriesSortedResult, MetaCacheEntry,
|
||||
MetadataResolutionParams,
|
||||
FileInfo, MetaCacheEntries, MetaCacheEntriesSorted, MetaCacheEntriesSortedResult, MetaCacheEntry, MetadataResolutionParams,
|
||||
merge_file_meta_versions,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
@@ -837,11 +837,7 @@ impl ECStore {
|
||||
if fiter(&fi) {
|
||||
let item = ObjectInfoOrErr {
|
||||
item: Some(ObjectInfo::from_file_info(&fi, &bucket, &fi.name, {
|
||||
if let Some(v) = &vcf {
|
||||
v.versioned(&fi.name)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
if let Some(v) = &vcf { v.versioned(&fi.name) } else { false }
|
||||
})),
|
||||
err: None,
|
||||
};
|
||||
@@ -853,11 +849,7 @@ impl ECStore {
|
||||
} else {
|
||||
let item = ObjectInfoOrErr {
|
||||
item: Some(ObjectInfo::from_file_info(&fi, &bucket, &fi.name, {
|
||||
if let Some(v) = &vcf {
|
||||
v.versioned(&fi.name)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
if let Some(v) = &vcf { v.versioned(&fi.name) } else { false }
|
||||
})),
|
||||
err: None,
|
||||
};
|
||||
@@ -892,12 +884,8 @@ impl ECStore {
|
||||
if let Some(fiter) = opts.filter {
|
||||
if fiter(fi) {
|
||||
let item = ObjectInfoOrErr {
|
||||
item: Some(ObjectInfo::from_file_info(&fi, &bucket, &fi.name, {
|
||||
if let Some(v) = &vcf {
|
||||
v.versioned(&fi.name)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
item: Some(ObjectInfo::from_file_info(fi, &bucket, &fi.name, {
|
||||
if let Some(v) = &vcf { v.versioned(&fi.name) } else { false }
|
||||
})),
|
||||
err: None,
|
||||
};
|
||||
@@ -908,12 +896,8 @@ impl ECStore {
|
||||
}
|
||||
} else {
|
||||
let item = ObjectInfoOrErr {
|
||||
item: Some(ObjectInfo::from_file_info(&fi, &bucket, &fi.name, {
|
||||
if let Some(v) = &vcf {
|
||||
v.versioned(&fi.name)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
item: Some(ObjectInfo::from_file_info(fi, &bucket, &fi.name, {
|
||||
if let Some(v) = &vcf { v.versioned(&fi.name) } else { false }
|
||||
})),
|
||||
err: None,
|
||||
};
|
||||
|
||||
@@ -188,8 +188,8 @@ pub fn parse_ellipses_range(pattern: &str) -> Result<Vec<String>> {
|
||||
}
|
||||
|
||||
// TODO: Add support for hexadecimals.
|
||||
let start = ellipses_range[0].parse::<usize>().map_err(|e| Error::other(e))?;
|
||||
let end = ellipses_range[1].parse::<usize>().map_err(|e| Error::other(e))?;
|
||||
let start = ellipses_range[0].parse::<usize>().map_err(Error::other)?;
|
||||
let end = ellipses_range[1].parse::<usize>().map_err(Error::other)?;
|
||||
|
||||
if start > end {
|
||||
return Err(Error::other("Invalid argument:range start cannot be bigger than end"));
|
||||
|
||||
@@ -53,10 +53,7 @@ pub fn is_local_host(host: Host<&str>, port: u16, local_port: u16) -> Result<boo
|
||||
let local_set: HashSet<IpAddr> = LOCAL_IPS.iter().copied().collect();
|
||||
let is_local_host = match host {
|
||||
Host::Domain(domain) => {
|
||||
let ips = match (domain, 0).to_socket_addrs().map(|v| v.map(|v| v.ip()).collect::<Vec<_>>()) {
|
||||
Ok(ips) => ips,
|
||||
Err(err) => return Err(err),
|
||||
};
|
||||
let ips = (domain, 0).to_socket_addrs().map(|v| v.map(|v| v.ip()).collect::<Vec<_>>())?;
|
||||
|
||||
ips.iter().any(|ip| local_set.contains(ip))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user