fix:Apply suggestions from clippy 1.88

This commit is contained in:
houseme
2025-06-27 18:16:29 +08:00
parent 35489ea352
commit 749537664f
108 changed files with 642 additions and 682 deletions
+2 -2
View File
@@ -102,9 +102,9 @@ async fn is_server_resolvable(endpoint: &Endpoint) -> Result<()> {
// 打印响应
let ping_response_body = flatbuffers::root::<PingBody>(&response.body);
if let Err(e) = ping_response_body {
eprintln!("{}", e);
eprintln!("{e}");
} else {
println!("ping_resp:body(flatbuffer): {:?}", ping_response_body);
println!("ping_resp:body(flatbuffer): {ping_response_body:?}");
}
Ok(())
+1 -1
View File
@@ -168,7 +168,7 @@ mod tests {
assert!(wrapper.is_err());
let error = wrapper.unwrap_err();
println!("error: {:?}", error);
println!("error: {error:?}");
assert_eq!(error, DiskError::DiskNotFound);
}
}
+1 -1
View File
@@ -285,7 +285,7 @@ impl BucketMetadata {
self.bucket_targets_config_json = data.clone();
self.bucket_targets_config_updated_at = updated;
}
_ => return Err(Error::other(format!("config file not found : {}", config_file))),
_ => return Err(Error::other(format!("config file not found : {config_file}"))),
}
Ok(updated)
+2 -2
View File
@@ -32,7 +32,7 @@ impl VersioningApi for VersioningConfiguration {
if let Some(ref excluded_prefixes) = self.excluded_prefixes {
for p in excluded_prefixes.iter() {
if let Some(ref sprefix) = p.prefix {
let pattern = format!("{}*", sprefix);
let pattern = format!("{sprefix}*");
if match_simple(&pattern, prefix) {
return false;
}
@@ -62,7 +62,7 @@ impl VersioningApi for VersioningConfiguration {
if let Some(ref excluded_prefixes) = self.excluded_prefixes {
for p in excluded_prefixes.iter() {
if let Some(ref sprefix) = p.prefix {
let pattern = format!("{}*", sprefix);
let pattern = format!("{sprefix}*");
if match_simple(&pattern, prefix) {
return true;
}
+12 -12
View File
@@ -394,7 +394,7 @@ pub async fn check_replicate_delete(
// use crate::global::*;
fn target_reset_header(arn: &str) -> String {
format!("{}{}-{}", RESERVED_METADATA_PREFIX_LOWER, REPLICATION_RESET, arn)
format!("{RESERVED_METADATA_PREFIX_LOWER}{REPLICATION_RESET}-{arn}")
}
pub async fn get_heal_replicate_object_info(
@@ -491,7 +491,7 @@ pub async fn get_heal_replicate_object_info(
let asz = oi.get_actual_size().unwrap_or(0);
let key = format!("{}{}", RESERVED_METADATA_PREFIX_LOWER, REPLICATION_TIMESTAMP);
let key = format!("{RESERVED_METADATA_PREFIX_LOWER}{REPLICATION_TIMESTAMP}");
let tm: Option<DateTime<Utc>> = user_defined
.get(&key)
.and_then(|v| DateTime::parse_from_rfc3339(v).ok())
@@ -819,7 +819,7 @@ impl ReplicationPool {
// }
fn get_worker_ch(&self, bucket: &str, object: &str, _sz: i64) -> Option<&Sender<Box<dyn ReplicationWorkerOperation>>> {
let h = xxh3_64(format!("{}{}", bucket, object).as_bytes()); // 计算哈希值
let h = xxh3_64(format!("{bucket}{object}").as_bytes()); // 计算哈希值
// need lock;
let workers = &self.workers_sender; // 读锁
@@ -1067,7 +1067,7 @@ impl fmt::Display for VersionPurgeStatusType {
VersionPurgeStatusType::Empty => "",
VersionPurgeStatusType::Unknown => "UNKNOWN",
};
write!(f, "{}", s)
write!(f, "{s}")
}
}
@@ -1307,7 +1307,7 @@ impl fmt::Display for ReplicateDecision {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut entries = Vec::new();
for (key, value) in &self.targets_map {
entries.push(format!("{}={}", key, value));
entries.push(format!("{key}={value}"));
}
write!(f, "{}", entries.join(","))
}
@@ -2123,7 +2123,7 @@ async fn replicate_object_with_multipart(
.provider(provider)
.secure(false)
.build()
.map_err(|e| Error::other(format!("build minio client failed: {}", e)))?;
.map_err(|e| Error::other(format!("build minio client failed: {e}")))?;
let ret = minio_cli
.create_multipart_upload_with_versionid(tgt_cli.bucket.clone(), local_obj_info.name.clone(), rep_obj.version_id.clone())
@@ -2168,7 +2168,7 @@ async fn replicate_object_with_multipart(
}
Err(err) => {
error!("upload part {} failed: {}", index + 1, err);
Err(Error::other(format!("upload error: {}", err)))
Err(Error::other(format!("upload error: {err}")))
}
}
}
@@ -2179,7 +2179,7 @@ async fn replicate_object_with_multipart(
},
Err(err) => {
error!("reader error for part {}: {}", index + 1, err);
Err(Error::other(format!("reader error: {}", err)))
Err(Error::other(format!("reader error: {err}")))
}
}
}));
@@ -2196,7 +2196,7 @@ async fn replicate_object_with_multipart(
}
Err(join_err) => {
error!("tokio join error: {}", join_err);
return Err(Error::other(format!("join error: {}", join_err)));
return Err(Error::other(format!("join error: {join_err}")));
}
}
}
@@ -2210,12 +2210,12 @@ async fn replicate_object_with_multipart(
}
Err(err) => {
error!("finish upload failed:{}", err);
return Err(Error::other(format!("finish upload failed:{}", err)));
return Err(Error::other(format!("finish upload failed:{err}")));
}
}
}
Err(err) => {
return Err(Error::other(format!("finish upload failed:{}", err)));
return Err(Error::other(format!("finish upload failed:{err}")));
}
}
Ok(())
@@ -2729,7 +2729,7 @@ pub async fn replicate_object(ri: ReplicateObjectInfo, object_api: Arc<store::EC
// }
}
Err(err) => {
println!("Failed to get replication config: {:?}", err);
println!("Failed to get replication config: {err:?}");
}
}
}
+9 -9
View File
@@ -147,7 +147,7 @@ pub struct BucketRemoteTargetNotFound {
}
pub async fn init_bucket_targets(bucket: &str, meta: Arc<bucket::metadata::BucketMetadata>) {
println!("140 {}", bucket);
println!("140 {bucket}");
if let Some(sys) = GLOBAL_Bucket_Target_Sys.get() {
if let Some(tgts) = meta.bucket_target_config.clone() {
for tgt in tgts.targets {
@@ -282,7 +282,7 @@ impl BucketTargetSys {
let _ = metadata_sys::update(bucket, "bucket-targets.json", json).await;
}
Err(e) => {
println!("序列化失败{}", e);
println!("序列化失败{e}");
}
}
@@ -379,11 +379,11 @@ impl BucketTargetSys {
// .get_bucket_info(bucket, &ecstore::store_api::BucketOptions::default()).await;
match store.get_bucket_info(_bucket, &store_api::BucketOptions::default()).await {
Ok(info) => {
println!("Bucket Info: {:?}", info);
println!("Bucket Info: {info:?}");
info.versionning
}
Err(err) => {
eprintln!("Error: {:?}", err);
eprintln!("Error: {err:?}");
false
}
}
@@ -433,7 +433,7 @@ impl BucketTargetSys {
let url_str = format!("http://{}", tgt.endpoint.clone());
println!("url str is {}", url_str);
println!("url str is {url_str}");
// 转换为 Url 类型
let parsed_url = url::Url::parse(&url_str).unwrap();
@@ -451,7 +451,7 @@ impl BucketTargetSys {
.await
{
Ok(info) => {
println!("Bucket Info: {:?}", info);
println!("Bucket Info: {info:?}");
if !info.versionning {
println!("2222222222 {}", info.versionning);
return Err(SetTargetError::TargetNotVersioned(tgt.target_bucket.to_string()));
@@ -459,7 +459,7 @@ impl BucketTargetSys {
}
Err(err) => {
println!("remote bucket 369 is:{}", tgt.target_bucket);
eprintln!("Error: {:?}", err);
eprintln!("Error: {err:?}");
return Err(SetTargetError::SourceNotVersioned(tgt.target_bucket.to_string()));
}
}
@@ -629,12 +629,12 @@ impl ARN {
pub fn parse(s: &str) -> Result<Self, String> {
// ARN 必须是格式 arn:rustfs:<Type>:<REGION>:<ID>:<remote-bucket>
if !s.starts_with("arn:rustfs:") {
return Err(format!("Invalid ARN {}", s));
return Err(format!("Invalid ARN {s}"));
}
let tokens: Vec<&str> = s.split(':').collect();
if tokens.len() != 6 || tokens[4].is_empty() || tokens[5].is_empty() {
return Err(format!("Invalid ARN {}", s));
return Err(format!("Invalid ARN {s}"));
}
Ok(ARN {
+1 -1
View File
@@ -116,7 +116,7 @@ async fn new_and_save_server_config<S: StorageAPI>(api: Arc<S>) -> Result<Config
}
fn get_config_file() -> String {
format!("{}{}{}", CONFIG_PREFIX, SLASH_SEPARATOR, CONFIG_FILE)
format!("{CONFIG_PREFIX}{SLASH_SEPARATOR}{CONFIG_FILE}")
}
/// Handle the situation where the configuration file does not exist, create and save a new configuration
+1 -2
View File
@@ -48,8 +48,7 @@ fn parse_bitrot_config(s: &str) -> Result<Duration> {
Ok(months) => {
if months < RUSTFS_BITROT_CYCLE_IN_MONTHS {
return Err(Error::other(format!(
"minimum bitrot cycle is {} month(s)",
RUSTFS_BITROT_CYCLE_IN_MONTHS
"minimum bitrot cycle is {RUSTFS_BITROT_CYCLE_IN_MONTHS} month(s)"
)));
}
+3 -5
View File
@@ -201,7 +201,7 @@ pub fn lookup_config(kvs: &KVS, set_drive_count: usize) -> Result<Config> {
}
block.as_u64() as usize
} else {
return Err(Error::other(format!("parse {} format failed", INLINE_BLOCK_ENV)));
return Err(Error::other(format!("parse {INLINE_BLOCK_ENV} format failed")));
}
} else {
DEFAULT_INLINE_BLOCK
@@ -223,8 +223,7 @@ pub fn parse_storage_class(env: &str) -> Result<StorageClass> {
// only two elements allowed in the string - "scheme" and "number of parity drives"
if s.len() != 2 {
return Err(Error::other(format!(
"Invalid storage class format: {}. Expected 'Scheme:Number of parity drives'.",
env
"Invalid storage class format: {env}. Expected 'Scheme:Number of parity drives'."
)));
}
@@ -300,8 +299,7 @@ pub fn validate_parity_inner(ss_parity: usize, rrs_parity: usize, set_drive_coun
if ss_parity > 0 && rrs_parity > 0 && ss_parity < rrs_parity {
return Err(Error::other(format!(
"Standard storage class parity drives {} should be greater than or equal to Reduced redundancy storage class parity drives {}",
ss_parity, rrs_parity
"Standard storage class parity drives {ss_parity} should be greater than or equal to Reduced redundancy storage class parity drives {rrs_parity}"
)));
}
Ok(())
+6 -6
View File
@@ -101,7 +101,7 @@ impl TryFrom<&str> for Endpoint {
is_local = true;
url_parse_from_file_path(value)?
}
_ => return Err(Error::other(format!("invalid URL endpoint format: {}", e))),
_ => return Err(Error::other(format!("invalid URL endpoint format: {e}"))),
},
};
@@ -163,8 +163,8 @@ impl Endpoint {
pub fn host_port(&self) -> String {
match (self.url.host(), self.url.port()) {
(Some(host), Some(port)) => format!("{}:{}", host, port),
(Some(host), None) => format!("{}", host),
(Some(host), Some(port)) => format!("{host}:{port}"),
(Some(host), None) => format!("{host}"),
_ => String::new(),
}
}
@@ -191,7 +191,7 @@ fn url_parse_from_file_path(value: &str) -> Result<Url> {
let file_path = match Path::new(value).absolutize() {
Ok(path) => path,
Err(err) => return Err(Error::other(format!("absolute path failed: {}", err))),
Err(err) => return Err(Error::other(format!("absolute path failed: {err}"))),
};
match Url::from_file_path(file_path) {
@@ -377,12 +377,12 @@ mod test {
fn test_endpoint_display() {
// Test file path display
let file_endpoint = Endpoint::try_from("/tmp/data").unwrap();
let display_str = format!("{}", file_endpoint);
let display_str = format!("{file_endpoint}");
assert_eq!(display_str, "/tmp/data");
// Test URL display
let url_endpoint = Endpoint::try_from("http://example.com:9000/path").unwrap();
let display_str = format!("{}", url_endpoint);
let display_str = format!("{url_endpoint}");
assert_eq!(display_str, "http://example.com:9000/path");
}
+3 -3
View File
@@ -693,7 +693,7 @@ mod tests {
source: io_error,
};
let display_str = format!("{}", context_error);
let display_str = format!("{context_error}");
assert!(display_str.contains("/test/path"));
assert!(display_str.contains("file access denied"));
}
@@ -701,11 +701,11 @@ mod tests {
#[test]
fn test_error_debug_format() {
let error = DiskError::FileNotFound;
let debug_str = format!("{:?}", error);
let debug_str = format!("{error:?}");
assert_eq!(debug_str, "FileNotFound");
let io_error = DiskError::other("test error");
let debug_str = format!("{:?}", io_error);
let debug_str = format!("{io_error:?}");
assert!(debug_str.contains("Io"));
}
+2 -6
View File
@@ -410,9 +410,7 @@ mod tests {
let result = to_file_error(create_io_error(kind));
assert!(
contains_disk_error(result, expected_disk_error.clone()),
"Failed for ErrorKind::{:?} -> DiskError::{:?}",
kind,
expected_disk_error
"Failed for ErrorKind::{kind:?} -> DiskError::{expected_disk_error:?}"
);
}
}
@@ -430,9 +428,7 @@ mod tests {
let result = to_volume_error(create_io_error(kind));
assert!(
contains_disk_error(result, expected_disk_error.clone()),
"Failed for ErrorKind::{:?} -> DiskError::{:?}",
kind,
expected_disk_error
"Failed for ErrorKind::{kind:?} -> DiskError::{expected_disk_error:?}"
);
}
}
+3 -3
View File
@@ -180,7 +180,7 @@ impl FormatV3 {
}
}
Err(Error::other(format!("disk id not found {}", disk_id)))
Err(Error::other(format!("disk id not found {disk_id}")))
}
pub fn check_other(&self, other: &FormatV3) -> Result<()> {
@@ -242,7 +242,7 @@ mod test {
let format = FormatV3::new(1, 4);
let str = serde_json::to_string(&format);
println!("{:?}", str);
println!("{str:?}");
let data = r#"
{
@@ -266,7 +266,7 @@ mod test {
let p = FormatV3::try_from(data);
println!("{:?}", p);
println!("{p:?}");
}
#[test]
+12 -12
View File
@@ -327,7 +327,7 @@ impl LocalDisk {
Ok(md)
}
async fn make_meta_volumes(&self) -> Result<()> {
let buckets = format!("{}/{}", RUSTFS_META_BUCKET, BUCKET_META_PREFIX);
let buckets = format!("{RUSTFS_META_BUCKET}/{BUCKET_META_PREFIX}");
let multipart = format!("{}/{}", RUSTFS_META_BUCKET, "multipart");
let config = format!("{}/{}", RUSTFS_META_BUCKET, "config");
let tmp = format!("{}/{}", RUSTFS_META_BUCKET, "tmp");
@@ -623,7 +623,7 @@ impl LocalDisk {
async fn delete_versions_internal(&self, volume: &str, path: &str, fis: &Vec<FileInfo>) -> Result<()> {
let volume_dir = self.get_bucket_path(volume)?;
let xlpath = self.get_object_path(volume, format!("{}/{}", path, STORAGE_FORMAT_FILE).as_str())?;
let xlpath = self.get_object_path(volume, format!("{path}/{STORAGE_FORMAT_FILE}").as_str())?;
let (data, _) = self.read_all_data_with_dmtime(volume, volume_dir.as_path(), &xlpath).await?;
@@ -652,7 +652,7 @@ impl LocalDisk {
let vid = fi.version_id.unwrap_or_default();
let _ = fm.data.remove(vec![vid, dir]);
let dir_path = self.get_object_path(volume, format!("{}/{}", path, dir).as_str())?;
let dir_path = self.get_object_path(volume, format!("{path}/{dir}").as_str())?;
if let Err(err) = self.move_to_trash(&dir_path, true, false).await {
if !(err == DiskError::FileNotFound || err == DiskError::VolumeNotFound) {
return Err(err);
@@ -674,7 +674,7 @@ impl LocalDisk {
self.write_all_private(
volume,
format!("{}/{}", path, STORAGE_FORMAT_FILE).as_str(),
format!("{path}/{STORAGE_FORMAT_FILE}").as_str(),
buf.into(),
true,
&volume_dir,
@@ -1399,7 +1399,7 @@ impl DiskAPI for LocalDisk {
rename_all(&src_file_path, &dst_file_path, &dst_volume_dir).await?;
self.write_all(dst_volume, format!("{}.meta", dst_path).as_str(), meta)
self.write_all(dst_volume, format!("{dst_path}.meta").as_str(), meta)
.await?;
if let Some(parent) = src_file_path.parent() {
@@ -1938,7 +1938,7 @@ impl DiskAPI for LocalDisk {
let wbuf = xl_meta.marshal_msg()?;
return self
.write_all_meta(volume, format!("{}/{}", path, STORAGE_FORMAT_FILE).as_str(), &wbuf, !opts.no_persistence)
.write_all_meta(volume, format!("{path}/{STORAGE_FORMAT_FILE}").as_str(), &wbuf, !opts.no_persistence)
.await;
}
@@ -1947,7 +1947,7 @@ impl DiskAPI for LocalDisk {
#[tracing::instrument(skip(self))]
async fn write_metadata(&self, _org_volume: &str, volume: &str, path: &str, fi: FileInfo) -> Result<()> {
let p = self.get_object_path(volume, format!("{}/{}", path, STORAGE_FORMAT_FILE).as_str())?;
let p = self.get_object_path(volume, format!("{path}/{STORAGE_FORMAT_FILE}").as_str())?;
let mut meta = FileMeta::new();
if !fi.fresh {
@@ -1963,7 +1963,7 @@ impl DiskAPI for LocalDisk {
let fm_data = meta.marshal_msg()?;
self.write_all(volume, format!("{}/{}", path, STORAGE_FORMAT_FILE).as_str(), fm_data.into())
self.write_all(volume, format!("{path}/{STORAGE_FORMAT_FILE}").as_str(), fm_data.into())
.await?;
Ok(())
@@ -2070,7 +2070,7 @@ impl DiskAPI for LocalDisk {
if !meta.versions.is_empty() {
let buf = meta.marshal_msg()?;
return self
.write_all_meta(volume, format!("{}{}{}", path, SLASH_SEPARATOR, STORAGE_FORMAT_FILE).as_str(), &buf, true)
.write_all_meta(volume, format!("{path}{SLASH_SEPARATOR}{STORAGE_FORMAT_FILE}").as_str(), &buf, true)
.await;
}
@@ -2078,9 +2078,9 @@ impl DiskAPI for LocalDisk {
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(),
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()));
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;
}
}
@@ -2250,7 +2250,7 @@ impl DiskAPI for LocalDisk {
let disk = disk_clone.clone();
let vcfg = vcfg.clone();
Box::pin(async move {
if !item.path.ends_with(&format!("{}{}", SLASH_SEPARATOR, STORAGE_FORMAT_FILE)) {
if !item.path.ends_with(&format!("{SLASH_SEPARATOR}{STORAGE_FORMAT_FILE}")) {
return Err(Error::other(ERR_SKIP_FILE).into());
}
let stop_fn = ScannerMetrics::log(ScannerMetric::ScanObject);
+4 -4
View File
@@ -189,7 +189,7 @@ fn get_all_sets<T: AsRef<str>>(set_drive_count: usize, is_ellipses: bool, args:
for args in set_args.iter() {
for arg in args {
if unique_args.contains(arg) {
return Err(Error::other(format!("Input args {} has duplicate ellipses", arg)));
return Err(Error::other(format!("Input args {arg} has duplicate ellipses")));
}
unique_args.insert(arg);
}
@@ -383,7 +383,7 @@ fn get_set_indexes<T: AsRef<str>>(
for &size in total_sizes {
// Check if total_sizes has minimum range upto set_size
if size < SET_SIZES[0] || size < set_drive_count {
return Err(Error::other(format!("Incorrect number of endpoints provided, size {}", size)));
return Err(Error::other(format!("Incorrect number of endpoints provided, size {size}")));
}
}
@@ -655,9 +655,9 @@ mod test {
let mut seq = Vec::new();
for i in start..=number {
if padding_len == 0 {
seq.push(format!("{}", i));
seq.push(format!("{i}"));
} else {
seq.push(format!("{:0width$}", i, width = padding_len));
seq.push(format!("{i:0padding_len$}"));
}
}
seq
+22 -24
View File
@@ -228,7 +228,7 @@ impl PoolEndpointList {
let host = ep.url.host().unwrap();
let host_ip_set = host_ip_cache.entry(host.clone()).or_insert({
get_host_ip(host.clone()).map_err(|e| Error::other(format!("host '{}' cannot resolve: {}", host, e)))?
get_host_ip(host.clone()).map_err(|e| Error::other(format!("host '{host}' cannot resolve: {e}")))?
});
let path = ep.get_file_path();
@@ -236,8 +236,7 @@ impl PoolEndpointList {
Entry::Occupied(mut e) => {
if e.get().intersection(host_ip_set).count() > 0 {
return Err(Error::other(format!(
"same path '{}' can not be served by different port on same address",
path
"same path '{path}' can not be served by different port on same address"
)));
}
e.get_mut().extend(host_ip_set.iter());
@@ -258,8 +257,7 @@ impl PoolEndpointList {
let path = ep.get_file_path();
if local_path_set.contains(path) {
return Err(Error::other(format!(
"path '{}' cannot be served by different address on same server",
path
"path '{path}' cannot be served by different address on same server"
)));
}
local_path_set.insert(path);
@@ -751,67 +749,67 @@ mod test {
}
let non_loop_back_ip = non_loop_back_i_ps[0];
let case1_endpoint1 = format!("http://{}/d1", non_loop_back_ip);
let case1_endpoint2 = format!("http://{}/d2", non_loop_back_ip);
let case1_endpoint1 = format!("http://{non_loop_back_ip}/d1");
let case1_endpoint2 = format!("http://{non_loop_back_ip}/d2");
let args = vec![
format!("http://{}:10000/d1", non_loop_back_ip),
format!("http://{}:10000/d2", non_loop_back_ip),
"http://example.org:10000/d3".to_string(),
"http://example.com:10000/d4".to_string(),
];
let (case1_ur_ls, case1_local_flags) = get_expected_endpoints(args, format!("http://{}:10000/", non_loop_back_ip));
let (case1_ur_ls, case1_local_flags) = get_expected_endpoints(args, format!("http://{non_loop_back_ip}:10000/"));
let case2_endpoint1 = format!("http://{}/d1", non_loop_back_ip);
let case2_endpoint2 = format!("http://{}:9000/d2", non_loop_back_ip);
let case2_endpoint1 = format!("http://{non_loop_back_ip}/d1");
let case2_endpoint2 = format!("http://{non_loop_back_ip}:9000/d2");
let args = vec![
format!("http://{}:10000/d1", non_loop_back_ip),
format!("http://{}:9000/d2", non_loop_back_ip),
"http://example.org:10000/d3".to_string(),
"http://example.com:10000/d4".to_string(),
];
let (case2_ur_ls, case2_local_flags) = get_expected_endpoints(args, format!("http://{}:10000/", non_loop_back_ip));
let (case2_ur_ls, case2_local_flags) = get_expected_endpoints(args, format!("http://{non_loop_back_ip}:10000/"));
let case3_endpoint1 = format!("http://{}/d1", non_loop_back_ip);
let case3_endpoint1 = format!("http://{non_loop_back_ip}/d1");
let args = vec![
format!("http://{}:80/d1", non_loop_back_ip),
"http://example.org:9000/d2".to_string(),
"http://example.com:80/d3".to_string(),
"http://example.net:80/d4".to_string(),
];
let (case3_ur_ls, case3_local_flags) = get_expected_endpoints(args, format!("http://{}:80/", non_loop_back_ip));
let (case3_ur_ls, case3_local_flags) = get_expected_endpoints(args, format!("http://{non_loop_back_ip}:80/"));
let case4_endpoint1 = format!("http://{}/d1", non_loop_back_ip);
let case4_endpoint1 = format!("http://{non_loop_back_ip}/d1");
let args = vec![
format!("http://{}:9000/d1", non_loop_back_ip),
"http://example.org:9000/d2".to_string(),
"http://example.com:9000/d3".to_string(),
"http://example.net:9000/d4".to_string(),
];
let (case4_ur_ls, case4_local_flags) = get_expected_endpoints(args, format!("http://{}:9000/", non_loop_back_ip));
let (case4_ur_ls, case4_local_flags) = get_expected_endpoints(args, format!("http://{non_loop_back_ip}:9000/"));
let case5_endpoint1 = format!("http://{}:9000/d1", non_loop_back_ip);
let case5_endpoint2 = format!("http://{}:9001/d2", non_loop_back_ip);
let case5_endpoint3 = format!("http://{}:9002/d3", non_loop_back_ip);
let case5_endpoint4 = format!("http://{}:9003/d4", non_loop_back_ip);
let case5_endpoint1 = format!("http://{non_loop_back_ip}:9000/d1");
let case5_endpoint2 = format!("http://{non_loop_back_ip}:9001/d2");
let case5_endpoint3 = format!("http://{non_loop_back_ip}:9002/d3");
let case5_endpoint4 = format!("http://{non_loop_back_ip}:9003/d4");
let args = vec![
case5_endpoint1.clone(),
case5_endpoint2.clone(),
case5_endpoint3.clone(),
case5_endpoint4.clone(),
];
let (case5_ur_ls, case5_local_flags) = get_expected_endpoints(args, format!("http://{}:9000/", non_loop_back_ip));
let (case5_ur_ls, case5_local_flags) = get_expected_endpoints(args, format!("http://{non_loop_back_ip}:9000/"));
let case6_endpoint1 = format!("http://{}:9003/d4", non_loop_back_ip);
let case6_endpoint1 = format!("http://{non_loop_back_ip}:9003/d4");
let args = vec![
"http://localhost:9000/d1".to_string(),
"http://localhost:9001/d2".to_string(),
"http://127.0.0.1:9002/d3".to_string(),
case6_endpoint1.clone(),
];
let (case6_ur_ls, case6_local_flags) = get_expected_endpoints(args, format!("http://{}:9003/", non_loop_back_ip));
let (case6_ur_ls, case6_local_flags) = get_expected_endpoints(args, format!("http://{non_loop_back_ip}:9003/"));
let case7_endpoint1 = format!("http://{}:9001/export", non_loop_back_ip);
let case7_endpoint2 = format!("http://{}:9000/export", non_loop_back_ip);
let case7_endpoint1 = format!("http://{non_loop_back_ip}:9001/export");
let case7_endpoint2 = format!("http://{non_loop_back_ip}:9000/export");
let test_cases = [
TestCase {
+1 -1
View File
@@ -128,7 +128,7 @@ impl Erasure {
total += n;
let res = self.encode_data(&buf[..n])?;
if let Err(err) = tx.send(res).await {
return Err(std::io::Error::other(format!("Failed to send encoded data : {}", err)));
return Err(std::io::Error::other(format!("Failed to send encoded data : {err}")));
}
}
Ok(_) => break,
+19 -19
View File
@@ -98,7 +98,7 @@ impl ReedSolomonEncoder {
warn!("Failed to reset SIMD encoder: {:?}, creating new one", e);
// 如果reset失败,创建新的encoder
reed_solomon_simd::ReedSolomonEncoder::new(self.data_shards, self.parity_shards, shard_len)
.map_err(|e| io::Error::other(format!("Failed to create SIMD encoder: {:?}", e)))?
.map_err(|e| io::Error::other(format!("Failed to create SIMD encoder: {e:?}")))?
} else {
cached_encoder
}
@@ -106,7 +106,7 @@ impl ReedSolomonEncoder {
None => {
// 第一次使用,创建新encoder
reed_solomon_simd::ReedSolomonEncoder::new(self.data_shards, self.parity_shards, shard_len)
.map_err(|e| io::Error::other(format!("Failed to create SIMD encoder: {:?}", e)))?
.map_err(|e| io::Error::other(format!("Failed to create SIMD encoder: {e:?}")))?
}
}
};
@@ -115,13 +115,13 @@ impl ReedSolomonEncoder {
for (i, shard) in shards_vec.iter().enumerate().take(self.data_shards) {
encoder
.add_original_shard(shard)
.map_err(|e| io::Error::other(format!("Failed to add shard {}: {:?}", i, e)))?;
.map_err(|e| io::Error::other(format!("Failed to add shard {i}: {e:?}")))?;
}
// 编码并获取恢复shards
let result = encoder
.encode()
.map_err(|e| io::Error::other(format!("SIMD encoding failed: {:?}", e)))?;
.map_err(|e| io::Error::other(format!("SIMD encoding failed: {e:?}")))?;
// 将恢复shards复制到输出缓冲区
for (i, recovery_shard) in result.recovery_iter().enumerate() {
@@ -176,7 +176,7 @@ impl ReedSolomonEncoder {
warn!("Failed to reset SIMD decoder: {:?}, creating new one", e);
// 如果reset失败,创建新的decoder
reed_solomon_simd::ReedSolomonDecoder::new(self.data_shards, self.parity_shards, shard_len)
.map_err(|e| io::Error::other(format!("Failed to create SIMD decoder: {:?}", e)))?
.map_err(|e| io::Error::other(format!("Failed to create SIMD decoder: {e:?}")))?
} else {
cached_decoder
}
@@ -184,7 +184,7 @@ impl ReedSolomonEncoder {
None => {
// 第一次使用,创建新decoder
reed_solomon_simd::ReedSolomonDecoder::new(self.data_shards, self.parity_shards, shard_len)
.map_err(|e| io::Error::other(format!("Failed to create SIMD decoder: {:?}", e)))?
.map_err(|e| io::Error::other(format!("Failed to create SIMD decoder: {e:?}")))?
}
}
};
@@ -195,19 +195,19 @@ impl ReedSolomonEncoder {
if i < self.data_shards {
decoder
.add_original_shard(i, shard)
.map_err(|e| io::Error::other(format!("Failed to add original shard for reconstruction: {:?}", e)))?;
.map_err(|e| io::Error::other(format!("Failed to add original shard for reconstruction: {e:?}")))?;
} else {
let recovery_idx = i - self.data_shards;
decoder
.add_recovery_shard(recovery_idx, shard)
.map_err(|e| io::Error::other(format!("Failed to add recovery shard for reconstruction: {:?}", e)))?;
.map_err(|e| io::Error::other(format!("Failed to add recovery shard for reconstruction: {e:?}")))?;
}
}
}
let result = decoder
.decode()
.map_err(|e| io::Error::other(format!("SIMD decode error: {:?}", e)))?;
.map_err(|e| io::Error::other(format!("SIMD decode error: {e:?}")))?;
// Fill in missing data shards from reconstruction result
for (i, shard_opt) in shards.iter_mut().enumerate() {
@@ -596,11 +596,11 @@ mod tests {
fn test_shard_file_offset() {
let erasure = Erasure::new(8, 8, 1024 * 1024);
let offset = erasure.shard_file_offset(0, 86, 86);
println!("offset={}", offset);
println!("offset={offset}");
assert!(offset > 0);
let total_length = erasure.shard_file_size(86);
println!("total_length={}", total_length);
println!("total_length={total_length}");
assert!(total_length > 0);
}
@@ -746,7 +746,7 @@ mod tests {
// Verify that all data shards are zeros
for (i, shard) in encoded_shards.iter().enumerate().take(data_shards) {
assert!(shard.iter().all(|&x| x == 0), "Data shard {} should be all zeros", i);
assert!(shard.iter().all(|&x| x == 0), "Data shard {i} should be all zeros");
}
// Test recovery with some shards missing
@@ -839,7 +839,7 @@ mod tests {
}
}
Err(e) => {
println!("SIMD encoding failed with small shard size: {}", e);
println!("SIMD encoding failed with small shard size: {e}");
// This is expected for very small shard sizes
}
}
@@ -909,19 +909,19 @@ mod tests {
recovered.extend_from_slice(shard.as_ref().unwrap());
}
recovered.truncate(small_data.len());
println!("recovered: {:?}", recovered);
println!("small_data: {:?}", small_data);
println!("recovered: {recovered:?}");
println!("small_data: {small_data:?}");
assert_eq!(&recovered, &small_data);
println!("✅ Data recovery successful with SIMD");
}
Err(e) => {
println!("❌ SIMD decode failed: {}", e);
println!("❌ SIMD decode failed: {e}");
// For very small data, decode failure might be acceptable
}
}
}
Err(e) => {
println!("❌ SIMD encode failed: {}", e);
println!("❌ SIMD encode failed: {e}");
// For very small data or configuration issues, encoding might fail
}
}
@@ -953,7 +953,7 @@ mod tests {
let shards = erasure.encode_data(&data).unwrap();
let encode_duration = start.elapsed();
println!("⏱️ Encoding completed in: {:?}", encode_duration);
println!("⏱️ Encoding completed in: {encode_duration:?}");
println!("📦 Generated {} shards, each shard size: {}KB", shards.len(), shards[0].len() / 1024);
assert_eq!(shards.len(), data_shards + parity_shards);
@@ -977,7 +977,7 @@ mod tests {
erasure.decode_data(&mut shards_opt).unwrap();
let decode_duration = start.elapsed();
println!("⏱️ Decoding completed in: {:?}", decode_duration);
println!("⏱️ Decoding completed in: {decode_duration:?}");
// 验证恢复的数据完整性
let mut recovered = Vec::new();
+1 -1
View File
@@ -39,7 +39,7 @@ impl super::Erasure {
let (mut shards, errs) = reader.read().await;
if errs.iter().filter(|e| e.is_none()).count() < self.data_shards {
return Err(Error::other(format!("can not reconstruct data: not enough data shards {:?}", errs)));
return Err(Error::other(format!("can not reconstruct data: not enough data shards {errs:?}")));
}
if self.parity_shards > 0 {
+3 -3
View File
@@ -806,7 +806,7 @@ pub fn error_resp_to_object_err(err: ErrorResponse, params: Vec<&str>) -> std::i
}
if is_network_or_host_down(&err.to_string(), false) {
return std::io::Error::other(ObjectApiError::BackendDown(format!("{}", err)));
return std::io::Error::other(ObjectApiError::BackendDown(format!("{err}")));
}
let r_err = err;
@@ -1118,7 +1118,7 @@ mod tests {
// For errors with parameters, we only check the variant type
assert_eq!(std::mem::discriminant(&original_error), std::mem::discriminant(&recovered_error));
} else {
panic!("Failed to recover error from code: {:#x}", code);
panic!("Failed to recover error from code: {code:#x}");
}
}
}
@@ -1211,7 +1211,7 @@ mod tests {
assert_eq!(inner_io.kind(), kind);
assert!(inner_io.to_string().contains(message));
}
_ => panic!("Expected StorageError::Io variant for kind: {:?}", kind),
_ => panic!("Expected StorageError::Io variant for kind: {kind:?}"),
}
}
}
+1 -2
View File
@@ -147,8 +147,7 @@ async fn heal_fresh_disk(endpoint: &Endpoint) -> Result<()> {
Some(disk) => disk,
None => {
return Err(Error::other(format!(
"Unexpected error disk must be initialized by now after formatting: {}",
endpoint
"Unexpected error disk must be initialized by now after formatting: {endpoint}"
)));
}
};
+1 -1
View File
@@ -487,7 +487,7 @@ impl CurrentScannerCycle {
Deserialize::deserialize(&mut Deserializer::new(&buf[..])).expect("Deserialization failed");
self.cycle_completed = u;
}
name => return Err(Error::other(format!("not support field name {}", name))),
name => return Err(Error::other(format!("not support field name {name}"))),
}
}
+1 -1
View File
@@ -372,7 +372,7 @@ impl ScannerMetrics {
for (disk, tracker) in paths.iter() {
let path = tracker.get_path().await;
result.push(format!("{}/{}", disk, path));
result.push(format!("{disk}/{path}"));
}
result
+3 -4
View File
@@ -318,7 +318,7 @@ impl HealSequence {
self.count_scanned(heal_type.clone()).await;
if source.no_wait {
let task_str = format!("{:?}", task);
let task_str = format!("{task:?}");
if GLOBAL_BackgroundHealRoutine.tasks_tx.try_send(task).is_ok() {
info!("Task in the queue: {:?}", task_str);
}
@@ -328,7 +328,7 @@ impl HealSequence {
let (resp_tx, mut resp_rx) = mpsc::channel(1);
task.resp_tx = Some(resp_tx);
let task_str = format!("{:?}", task);
let task_str = format!("{task:?}");
if GLOBAL_BackgroundHealRoutine.tasks_tx.try_send(task).is_ok() {
info!("Task in the queue: {:?}", task_str);
} else {
@@ -793,8 +793,7 @@ impl AllHealState {
for (k, v) in self.heal_seq_map.read().await.iter() {
if (has_prefix(k, path_s) || has_prefix(path_s, k)) && !v.has_ended().await {
return Err(Error::other(format!(
"The provided heal sequence path overlaps with an existing heal path: {}",
k
"The provided heal sequence path overlaps with an existing heal path: {k}"
)));
}
}
+2 -2
View File
@@ -121,11 +121,11 @@ impl PoolMeta {
};
let format = LittleEndian::read_u16(&data[0..2]);
if format != POOL_META_FORMAT {
return Err(Error::other(format!("PoolMeta: unknown format: {}", format)));
return Err(Error::other(format!("PoolMeta: unknown format: {format}")));
}
let version = LittleEndian::read_u16(&data[2..4]);
if version != POOL_META_VERSION {
return Err(Error::other(format!("PoolMeta: unknown version: {}", version)));
return Err(Error::other(format!("PoolMeta: unknown version: {version}")));
}
let mut buf = Deserializer::new(Cursor::new(&data[4..]));
+7 -7
View File
@@ -95,7 +95,7 @@ impl fmt::Display for RebalStatus {
RebalStatus::Stopped => "Stopped",
RebalStatus::Failed => "Failed",
};
write!(f, "{}", status)
write!(f, "{status}")
}
}
@@ -172,11 +172,11 @@ impl RebalanceMeta {
// Read header
match u16::from_le_bytes([data[0], data[1]]) {
REBAL_META_FMT => {}
fmt => return Err(Error::other(format!("rebalanceMeta load_with_opts: unknown format: {}", fmt))),
fmt => return Err(Error::other(format!("rebalanceMeta load_with_opts: unknown format: {fmt}"))),
}
match u16::from_le_bytes([data[2], data[3]]) {
REBAL_META_VER => {}
ver => return Err(Error::other(format!("rebalanceMeta load_with_opts: unknown version: {}", ver))),
ver => return Err(Error::other(format!("rebalanceMeta load_with_opts: unknown version: {ver}"))),
}
let meta: Self = rmp_serde::from_read(Cursor::new(&data[4..]))?;
@@ -586,16 +586,16 @@ impl ECStore {
let state = match result {
Ok(_) => {
info!("rebalance_buckets: completed");
msg = format!("Rebalance completed at {:?}", now);
msg = format!("Rebalance completed at {now:?}");
RebalStatus::Completed},
Err(err) => {
info!("rebalance_buckets: error: {:?}", err);
// TODO: check stop
if err.to_string().contains("canceled") {
msg = format!("Rebalance stopped at {:?}", now);
msg = format!("Rebalance stopped at {now:?}");
RebalStatus::Stopped
} else {
msg = format!("Rebalance stopped at {:?} with err {:?}", now, err);
msg = format!("Rebalance stopped at {now:?} with err {err:?}");
RebalStatus::Failed
}
}
@@ -616,7 +616,7 @@ impl ECStore {
}
_ = timer.tick() => {
let now = OffsetDateTime::now_utc();
msg = format!("Saving rebalance metadata at {:?}", now);
msg = format!("Saving rebalance metadata at {now:?}");
}
}
+2 -2
View File
@@ -34,7 +34,7 @@ fn generate_signature(secret: &str, url: &str, method: &Method, timestamp: i64)
let url = path_and_query.to_string();
let data = format!("{}|{}|{}", url, method, timestamp);
let data = format!("{url}|{method}|{timestamp}");
let mut mac = HmacSha256::new_from_slice(secret.as_bytes()).expect("HMAC can take key of any size");
mac.update(data.as_bytes());
let result = mac.finalize();
@@ -369,7 +369,7 @@ mod tests {
// Verify the signature should succeed
let result = verify_rpc_signature(url, &method, &headers);
assert!(result.is_ok(), "Round-trip test failed for {} {}", method, url);
assert!(result.is_ok(), "Round-trip test failed for {method} {url}");
}
}
}
+5 -5
View File
@@ -513,7 +513,7 @@ impl PeerS3Client for RemotePeerS3Client {
let options: String = serde_json::to_string(opts)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(HealBucketRequest {
bucket: bucket.to_string(),
options,
@@ -539,7 +539,7 @@ impl PeerS3Client for RemotePeerS3Client {
let options = serde_json::to_string(opts)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(ListBucketRequest { options });
let response = client.list_bucket(request).await?.into_inner();
if !response.success {
@@ -561,7 +561,7 @@ impl PeerS3Client for RemotePeerS3Client {
let options = serde_json::to_string(opts)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(MakeBucketRequest {
name: bucket.to_string(),
options,
@@ -583,7 +583,7 @@ impl PeerS3Client for RemotePeerS3Client {
let options = serde_json::to_string(opts)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(GetBucketInfoRequest {
bucket: bucket.to_string(),
options,
@@ -604,7 +604,7 @@ impl PeerS3Client for RemotePeerS3Client {
async fn delete_bucket(&self, bucket: &str, _opts: &DeleteBucketOptions) -> Result<()> {
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(DeleteBucketRequest {
bucket: bucket.to_string(),
+25 -25
View File
@@ -154,7 +154,7 @@ impl DiskAPI for RemoteDisk {
info!("make_volume");
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(MakeVolumeRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -174,7 +174,7 @@ impl DiskAPI for RemoteDisk {
info!("make_volumes");
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(MakeVolumesRequest {
disk: self.endpoint.to_string(),
volumes: volumes.iter().map(|s| (*s).to_string()).collect(),
@@ -194,7 +194,7 @@ impl DiskAPI for RemoteDisk {
info!("list_volumes");
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(ListVolumesRequest {
disk: self.endpoint.to_string(),
});
@@ -219,7 +219,7 @@ impl DiskAPI for RemoteDisk {
info!("stat_volume");
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(StatVolumeRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -241,7 +241,7 @@ impl DiskAPI for RemoteDisk {
info!("delete_volume {}/{}", self.endpoint.to_string(), volume);
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(DeleteVolumeRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -321,7 +321,7 @@ impl DiskAPI for RemoteDisk {
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(DeleteVersionRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -357,7 +357,7 @@ impl DiskAPI for RemoteDisk {
}
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(DeleteVersionsRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -391,7 +391,7 @@ impl DiskAPI for RemoteDisk {
let paths = paths.to_owned();
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(DeletePathsRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -413,7 +413,7 @@ impl DiskAPI for RemoteDisk {
let file_info = serde_json::to_string(&fi)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(WriteMetadataRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -438,7 +438,7 @@ impl DiskAPI for RemoteDisk {
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(UpdateMetadataRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -469,7 +469,7 @@ impl DiskAPI for RemoteDisk {
let opts = serde_json::to_string(opts)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(ReadVersionRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -494,7 +494,7 @@ impl DiskAPI for RemoteDisk {
info!("read_xl {}/{}/{}", self.endpoint.to_string(), volume, path);
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(ReadXlRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -526,7 +526,7 @@ impl DiskAPI for RemoteDisk {
let file_info = serde_json::to_string(&fi)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(RenameDataRequest {
disk: self.endpoint.to_string(),
src_volume: src_volume.to_string(),
@@ -552,7 +552,7 @@ impl DiskAPI for RemoteDisk {
info!("list_dir {}/{}", volume, _dir_path);
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(ListDirRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -687,7 +687,7 @@ impl DiskAPI for RemoteDisk {
info!("rename_file");
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(RenameFileRequest {
disk: self.endpoint.to_string(),
src_volume: src_volume.to_string(),
@@ -710,7 +710,7 @@ impl DiskAPI for RemoteDisk {
info!("rename_part {}/{}", src_volume, src_path);
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(RenamePartRequest {
disk: self.endpoint.to_string(),
src_volume: src_volume.to_string(),
@@ -735,7 +735,7 @@ impl DiskAPI for RemoteDisk {
let options = serde_json::to_string(&opt)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(DeleteRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -758,7 +758,7 @@ impl DiskAPI for RemoteDisk {
let file_info = serde_json::to_string(&fi)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(VerifyFileRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -783,7 +783,7 @@ impl DiskAPI for RemoteDisk {
let file_info = serde_json::to_string(&fi)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(CheckPartsRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -808,7 +808,7 @@ impl DiskAPI for RemoteDisk {
let read_multiple_req = serde_json::to_string(&req)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(ReadMultipleRequest {
disk: self.endpoint.to_string(),
read_multiple_req,
@@ -834,7 +834,7 @@ impl DiskAPI for RemoteDisk {
info!("write_all");
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(WriteAllRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -856,7 +856,7 @@ impl DiskAPI for RemoteDisk {
info!("read_all {}/{}", volume, path);
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(ReadAllRequest {
disk: self.endpoint.to_string(),
volume: volume.to_string(),
@@ -877,7 +877,7 @@ impl DiskAPI for RemoteDisk {
let opts = serde_json::to_string(&opts)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let request = Request::new(DiskInfoRequest {
disk: self.endpoint.to_string(),
opts,
@@ -906,7 +906,7 @@ impl DiskAPI for RemoteDisk {
let cache = serde_json::to_string(cache)?;
let mut client = node_service_time_out_client(&self.addr)
.await
.map_err(|err| Error::other(format!("can not get client, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not get client, err: {err}")))?;
let (tx, rx) = mpsc::channel(10);
let in_stream = ReceiverStream::new(rx);
@@ -918,7 +918,7 @@ impl DiskAPI for RemoteDisk {
};
tx.send(request)
.await
.map_err(|err| Error::other(format!("can not send request, err: {}", err)))?;
.map_err(|err| Error::other(format!("can not send request, err: {err}")))?;
loop {
match response.next().await {
+45 -45
View File
@@ -121,7 +121,7 @@ impl Node for NodeService {
Err(err) => {
return Ok(tonic::Response::new(HealBucketResponse {
success: false,
error: Some(DiskError::other(format!("decode HealOpts failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode HealOpts failed: {err}")).into()),
}));
}
};
@@ -149,7 +149,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(ListBucketResponse {
success: false,
bucket_infos: Vec::new(),
error: Some(DiskError::other(format!("decode BucketOptions failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode BucketOptions failed: {err}")).into()),
}));
}
};
@@ -183,7 +183,7 @@ impl Node for NodeService {
Err(err) => {
return Ok(tonic::Response::new(MakeBucketResponse {
success: false,
error: Some(DiskError::other(format!("decode MakeBucketOptions failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode MakeBucketOptions failed: {err}")).into()),
}));
}
};
@@ -209,7 +209,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(GetBucketInfoResponse {
success: false,
bucket_info: String::new(),
error: Some(DiskError::other(format!("decode BucketOptions failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode BucketOptions failed: {err}")).into()),
}));
}
};
@@ -221,7 +221,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(GetBucketInfoResponse {
success: false,
bucket_info: String::new(),
error: Some(DiskError::other(format!("encode data failed: {}", err)).into()),
error: Some(DiskError::other(format!("encode data failed: {err}")).into()),
}));
}
};
@@ -323,7 +323,7 @@ impl Node for NodeService {
Err(err) => {
return Ok(tonic::Response::new(DeleteResponse {
success: false,
error: Some(DiskError::other(format!("decode DeleteOptions failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode DeleteOptions failed: {err}")).into()),
}));
}
};
@@ -354,7 +354,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(VerifyFileResponse {
success: false,
check_parts_resp: "".to_string(),
error: Some(DiskError::other(format!("decode FileInfo failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode FileInfo failed: {err}")).into()),
}));
}
};
@@ -366,7 +366,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(VerifyFileResponse {
success: false,
check_parts_resp: String::new(),
error: Some(DiskError::other(format!("encode data failed: {}", err)).into()),
error: Some(DiskError::other(format!("encode data failed: {err}")).into()),
}));
}
};
@@ -400,7 +400,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(CheckPartsResponse {
success: false,
check_parts_resp: "".to_string(),
error: Some(DiskError::other(format!("decode FileInfo failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode FileInfo failed: {err}")).into()),
}));
}
};
@@ -412,7 +412,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(CheckPartsResponse {
success: false,
check_parts_resp: String::new(),
error: Some(DiskError::other(format!("encode data failed: {}", err)).into()),
error: Some(DiskError::other(format!("encode data failed: {err}")).into()),
}));
}
};
@@ -773,7 +773,7 @@ impl Node for NodeService {
let (rd, mut wr) = tokio::io::duplex(64);
let job1 = spawn(async move {
if let Err(err) = disk.walk_dir(opts, &mut wr).await {
println!("walk_dir err {:?}", err);
println!("walk_dir err {err:?}");
}
});
let job2 = spawn(async move {
@@ -829,7 +829,7 @@ impl Node for NodeService {
break;
}
println!("get err {:?}", err);
println!("get err {err:?}");
let _ = tx
.send(Ok(WalkDirResponse {
@@ -862,7 +862,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(RenameDataResponse {
success: false,
rename_data_resp: String::new(),
error: Some(DiskError::other(format!("decode FileInfo failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode FileInfo failed: {err}")).into()),
}));
}
};
@@ -877,7 +877,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(RenameDataResponse {
success: false,
rename_data_resp: String::new(),
error: Some(DiskError::other(format!("encode data failed: {}", err)).into()),
error: Some(DiskError::other(format!("encode data failed: {err}")).into()),
}));
}
};
@@ -987,7 +987,7 @@ impl Node for NodeService {
Err(err) => Ok(tonic::Response::new(StatVolumeResponse {
success: false,
volume_info: String::new(),
error: Some(DiskError::other(format!("encode data failed: {}", err)).into()),
error: Some(DiskError::other(format!("encode data failed: {err}")).into()),
})),
},
Err(err) => Ok(tonic::Response::new(StatVolumeResponse {
@@ -1034,7 +1034,7 @@ impl Node for NodeService {
Err(err) => {
return Ok(tonic::Response::new(UpdateMetadataResponse {
success: false,
error: Some(DiskError::other(format!("decode FileInfo failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode FileInfo failed: {err}")).into()),
}));
}
};
@@ -1043,7 +1043,7 @@ impl Node for NodeService {
Err(err) => {
return Ok(tonic::Response::new(UpdateMetadataResponse {
success: false,
error: Some(DiskError::other(format!("decode UpdateMetadataOpts failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode UpdateMetadataOpts failed: {err}")).into()),
}));
}
};
@@ -1074,7 +1074,7 @@ impl Node for NodeService {
Err(err) => {
return Ok(tonic::Response::new(WriteMetadataResponse {
success: false,
error: Some(DiskError::other(format!("decode FileInfo failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode FileInfo failed: {err}")).into()),
}));
}
};
@@ -1105,7 +1105,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(ReadVersionResponse {
success: false,
file_info: String::new(),
error: Some(DiskError::other(format!("decode ReadOptions failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode ReadOptions failed: {err}")).into()),
}));
}
};
@@ -1122,7 +1122,7 @@ impl Node for NodeService {
Err(err) => Ok(tonic::Response::new(ReadVersionResponse {
success: false,
file_info: String::new(),
error: Some(DiskError::other(format!("encode data failed: {}", err)).into()),
error: Some(DiskError::other(format!("encode data failed: {err}")).into()),
})),
},
Err(err) => Ok(tonic::Response::new(ReadVersionResponse {
@@ -1153,7 +1153,7 @@ impl Node for NodeService {
Err(err) => Ok(tonic::Response::new(ReadXlResponse {
success: false,
raw_file_info: String::new(),
error: Some(DiskError::other(format!("encode data failed: {}", err)).into()),
error: Some(DiskError::other(format!("encode data failed: {err}")).into()),
})),
},
Err(err) => Ok(tonic::Response::new(ReadXlResponse {
@@ -1180,7 +1180,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(DeleteVersionResponse {
success: false,
raw_file_info: "".to_string(),
error: Some(DiskError::other(format!("decode FileInfo failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode FileInfo failed: {err}")).into()),
}));
}
};
@@ -1190,7 +1190,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(DeleteVersionResponse {
success: false,
raw_file_info: "".to_string(),
error: Some(DiskError::other(format!("decode DeleteOptions failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode DeleteOptions failed: {err}")).into()),
}));
}
};
@@ -1207,7 +1207,7 @@ impl Node for NodeService {
Err(err) => Ok(tonic::Response::new(DeleteVersionResponse {
success: false,
raw_file_info: "".to_string(),
error: Some(DiskError::other(format!("encode data failed: {}", err)).into()),
error: Some(DiskError::other(format!("encode data failed: {err}")).into()),
})),
},
Err(err) => Ok(tonic::Response::new(DeleteVersionResponse {
@@ -1236,7 +1236,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(DeleteVersionsResponse {
success: false,
errors: Vec::new(),
error: Some(DiskError::other(format!("decode FileInfoVersions failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode FileInfoVersions failed: {err}")).into()),
}));
}
};
@@ -1247,7 +1247,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(DeleteVersionsResponse {
success: false,
errors: Vec::new(),
error: Some(DiskError::other(format!("decode DeleteOptions failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode DeleteOptions failed: {err}")).into()),
}));
}
};
@@ -1291,7 +1291,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(ReadMultipleResponse {
success: false,
read_multiple_resps: Vec::new(),
error: Some(DiskError::other(format!("decode ReadMultipleReq failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode ReadMultipleReq failed: {err}")).into()),
}));
}
};
@@ -1353,7 +1353,7 @@ impl Node for NodeService {
return Ok(tonic::Response::new(DiskInfoResponse {
success: false,
disk_info: "".to_string(),
error: Some(DiskError::other(format!("decode DiskInfoOptions failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode DiskInfoOptions failed: {err}")).into()),
}));
}
};
@@ -1367,7 +1367,7 @@ impl Node for NodeService {
Err(err) => Ok(tonic::Response::new(DiskInfoResponse {
success: false,
disk_info: "".to_string(),
error: Some(DiskError::other(format!("encode data failed: {}", err)).into()),
error: Some(DiskError::other(format!("encode data failed: {err}")).into()),
})),
},
Err(err) => Ok(tonic::Response::new(DiskInfoResponse {
@@ -1403,7 +1403,7 @@ impl Node for NodeService {
success: false,
update: "".to_string(),
data_usage_cache: "".to_string(),
error: Some(DiskError::other(format!("decode DataUsageCache failed: {}", err)).into()),
error: Some(DiskError::other(format!("decode DataUsageCache failed: {err}")).into()),
}))
.await
.expect("working rx");
@@ -1485,12 +1485,12 @@ impl Node for NodeService {
})),
Err(err) => Ok(tonic::Response::new(GenerallyLockResponse {
success: false,
error_info: Some(format!("can not lock, args: {}, err: {}", args, err)),
error_info: Some(format!("can not lock, args: {args}, err: {err}")),
})),
},
Err(err) => Ok(tonic::Response::new(GenerallyLockResponse {
success: false,
error_info: Some(format!("can not decode args, err: {}", err)),
error_info: Some(format!("can not decode args, err: {err}")),
})),
}
}
@@ -1505,12 +1505,12 @@ impl Node for NodeService {
})),
Err(err) => Ok(tonic::Response::new(GenerallyLockResponse {
success: false,
error_info: Some(format!("can not unlock, args: {}, err: {}", args, err)),
error_info: Some(format!("can not unlock, args: {args}, err: {err}")),
})),
},
Err(err) => Ok(tonic::Response::new(GenerallyLockResponse {
success: false,
error_info: Some(format!("can not decode args, err: {}", err)),
error_info: Some(format!("can not decode args, err: {err}")),
})),
}
}
@@ -1525,12 +1525,12 @@ impl Node for NodeService {
})),
Err(err) => Ok(tonic::Response::new(GenerallyLockResponse {
success: false,
error_info: Some(format!("can not rlock, args: {}, err: {}", args, err)),
error_info: Some(format!("can not rlock, args: {args}, err: {err}")),
})),
},
Err(err) => Ok(tonic::Response::new(GenerallyLockResponse {
success: false,
error_info: Some(format!("can not decode args, err: {}", err)),
error_info: Some(format!("can not decode args, err: {err}")),
})),
}
}
@@ -1545,12 +1545,12 @@ impl Node for NodeService {
})),
Err(err) => Ok(tonic::Response::new(GenerallyLockResponse {
success: false,
error_info: Some(format!("can not runlock, args: {}, err: {}", args, err)),
error_info: Some(format!("can not runlock, args: {args}, err: {err}")),
})),
},
Err(err) => Ok(tonic::Response::new(GenerallyLockResponse {
success: false,
error_info: Some(format!("can not decode args, err: {}", err)),
error_info: Some(format!("can not decode args, err: {err}")),
})),
}
}
@@ -1565,12 +1565,12 @@ impl Node for NodeService {
})),
Err(err) => Ok(tonic::Response::new(GenerallyLockResponse {
success: false,
error_info: Some(format!("can not force_unlock, args: {}, err: {}", args, err)),
error_info: Some(format!("can not force_unlock, args: {args}, err: {err}")),
})),
},
Err(err) => Ok(tonic::Response::new(GenerallyLockResponse {
success: false,
error_info: Some(format!("can not decode args, err: {}", err)),
error_info: Some(format!("can not decode args, err: {err}")),
})),
}
}
@@ -1585,12 +1585,12 @@ impl Node for NodeService {
})),
Err(err) => Ok(tonic::Response::new(GenerallyLockResponse {
success: false,
error_info: Some(format!("can not refresh, args: {}, err: {}", args, err)),
error_info: Some(format!("can not refresh, args: {args}, err: {err}")),
})),
},
Err(err) => Ok(tonic::Response::new(GenerallyLockResponse {
success: false,
error_info: Some(format!("can not decode args, err: {}", err)),
error_info: Some(format!("can not decode args, err: {err}")),
})),
}
}
@@ -3595,7 +3595,7 @@ mod tests {
#[test]
fn test_node_service_debug() {
let service = create_test_node_service();
let debug_str = format!("{:?}", service);
let debug_str = format!("{service:?}");
assert!(debug_str.contains("NodeService"));
}
@@ -3605,8 +3605,8 @@ mod tests {
let service2 = make_server();
// Both services should be created successfully
assert!(format!("{:?}", service1).contains("NodeService"));
assert!(format!("{:?}", service2).contains("NodeService"));
assert!(format!("{service1:?}").contains("NodeService"));
assert!(format!("{service2:?}").contains("NodeService"));
}
#[tokio::test]
+16 -17
View File
@@ -467,7 +467,7 @@ impl SetDisks {
data_dir: &str,
write_quorum: usize,
) -> disk::error::Result<()> {
let file_path = Arc::new(format!("{}/{}", object, data_dir));
let file_path = Arc::new(format!("{object}/{data_dir}"));
let bucket = Arc::new(bucket.to_string());
let futures = disks.iter().map(|disk| {
let file_path = file_path.clone();
@@ -585,7 +585,7 @@ impl SetDisks {
if let Some(err) = reduce_write_quorum_errs(&errs, OBJECT_OP_IGNORED_ERRS, write_quorum) {
warn!("rename_part errs {:?}", &errs);
Self::cleanup_multipart_path(disks, &[dst_object.to_string(), format!("{}.meta", dst_object)]).await;
Self::cleanup_multipart_path(disks, &[dst_object.to_string(), format!("{dst_object}.meta")]).await;
return Err(err);
}
@@ -723,7 +723,7 @@ impl SetDisks {
}
fn get_multipart_sha_dir(bucket: &str, object: &str) -> String {
let path = format!("{}/{}", bucket, object);
let path = format!("{bucket}/{object}");
let mut hasher = Sha256::new();
hasher.update(path);
hex(hasher.finalize())
@@ -1966,7 +1966,7 @@ impl SetDisks {
return Err(to_object_err(read_err.into(), vec![bucket, object]));
}
error!("create_bitrot_reader not enough disks to read: {:?}", &errors);
return Err(Error::other(format!("not enough disks to read: {:?}", errors)));
return Err(Error::other(format!("not enough disks to read: {errors:?}")));
}
// debug!(
@@ -2161,7 +2161,7 @@ impl SetDisks {
_ = list_path_raw(rx, lopts)
.await
.map_err(|err| Error::other(format!("listPathRaw returned {}: bucket: {}, path: {}", err, bucket, path)));
.map_err(|err| Error::other(format!("listPathRaw returned {err}: bucket: {bucket}, path: {path}")));
Ok(())
}
@@ -2677,8 +2677,7 @@ impl SetDisks {
return Ok((
result,
Some(DiskError::other(format!(
"all drives had write errors, unable to heal {}/{}",
bucket, object
"all drives had write errors, unable to heal {bucket}/{object}"
))),
));
}
@@ -2955,7 +2954,7 @@ impl SetDisks {
tags.insert("set", self.set_index.to_string());
tags.insert("pool", self.pool_index.to_string());
tags.insert("merrs", join_errs(errs));
tags.insert("derrs", format!("{:?}", data_errs_by_part));
tags.insert("derrs", format!("{data_errs_by_part:?}"));
if m.is_valid() {
tags.insert("sz", m.size.to_string());
tags.insert(
@@ -3268,7 +3267,7 @@ impl SetDisks {
Ok(info) => info,
Err(err) => {
defer.await;
return Err(Error::other(format!("unable to get disk information before healing it: {}", err)));
return Err(Error::other(format!("unable to get disk information before healing it: {err}")));
}
};
let num_cores = num_cpus::get(); // 使用 num_cpus crate 获取核心数
@@ -4010,7 +4009,7 @@ impl ObjectIO for SetDisks {
return Err(to_object_err(write_err.into(), vec![bucket, object]));
}
return Err(Error::other(format!("not enough disks to write: {:?}", errors)));
return Err(Error::other(format!("not enough disks to write: {errors:?}")));
}
let stream = mem::replace(
@@ -4035,8 +4034,8 @@ impl ObjectIO for SetDisks {
return Err(Error::other("put_object write size < data.size()"));
}
if user_defined.contains_key(&format!("{}compression", RESERVED_METADATA_PREFIX_LOWER)) {
user_defined.insert(format!("{}compression-size", RESERVED_METADATA_PREFIX_LOWER), w_size.to_string());
if user_defined.contains_key(&format!("{RESERVED_METADATA_PREFIX_LOWER}compression")) {
user_defined.insert(format!("{RESERVED_METADATA_PREFIX_LOWER}compression-size"), w_size.to_string());
}
let index_op = data.stream.try_get_index().map(|v| v.clone().into_vec());
@@ -4879,9 +4878,9 @@ impl StorageAPI for SetDisks {
let disks = disks.clone();
let shuffle_disks = Self::shuffle_disks(&disks, &fi.erasure.distribution);
let part_suffix = format!("part.{}", part_id);
let part_suffix = format!("part.{part_id}");
let tmp_part = format!("{}x{}", Uuid::new_v4(), OffsetDateTime::now_utc().unix_timestamp());
let tmp_part_path = Arc::new(format!("{}/{}", tmp_part, part_suffix));
let tmp_part_path = Arc::new(format!("{tmp_part}/{part_suffix}"));
// let mut writers = Vec::with_capacity(disks.len());
// let erasure = Erasure::new(fi.erasure.data_blocks, fi.erasure.parity_blocks, fi.erasure.block_size);
@@ -4979,7 +4978,7 @@ impl StorageAPI for SetDisks {
return Err(to_object_err(write_err.into(), vec![bucket, object]));
}
return Err(Error::other(format!("not enough disks to write: {:?}", errors)));
return Err(Error::other(format!("not enough disks to write: {errors:?}")));
}
let stream = mem::replace(
@@ -5473,11 +5472,11 @@ impl StorageAPI for SetDisks {
fi.metadata.insert("etag".to_owned(), etag);
fi.metadata
.insert(format!("{}actual-size", RESERVED_METADATA_PREFIX_LOWER), object_actual_size.to_string());
.insert(format!("{RESERVED_METADATA_PREFIX_LOWER}actual-size"), object_actual_size.to_string());
if fi.is_compressed() {
fi.metadata
.insert(format!("{}compression-size", RESERVED_METADATA_PREFIX_LOWER), object_size.to_string());
.insert(format!("{RESERVED_METADATA_PREFIX_LOWER}compression-size"), object_size.to_string());
}
if opts.data_movement {
+5 -5
View File
@@ -1446,7 +1446,7 @@ impl StorageAPI for ECStore {
// TODO: replication opts.srdelete_op
// 删除 meta
self.delete_all(RUSTFS_META_BUCKET, format!("{}/{}", BUCKET_META_PREFIX, bucket).as_str())
self.delete_all(RUSTFS_META_BUCKET, format!("{BUCKET_META_PREFIX}/{bucket}").as_str())
.await?;
Ok(())
}
@@ -2096,7 +2096,7 @@ impl StorageAPI for ECStore {
if pool_idx < self.pools.len() && set_idx < self.pools[pool_idx].disk_set.len() {
self.pools[pool_idx].disk_set[set_idx].get_disks(0, 0).await
} else {
Err(Error::other(format!("pool idx {}, set idx {}, not found", pool_idx, set_idx)))
Err(Error::other(format!("pool idx {pool_idx}, set idx {set_idx}, not found")))
}
}
@@ -2458,11 +2458,11 @@ async fn init_local_peer(endpoint_pools: &EndpointServerPools, host: &String, po
if peer_set.is_empty() {
if !host.is_empty() {
*GLOBAL_Local_Node_Name.write().await = format!("{}:{}", host, port);
*GLOBAL_Local_Node_Name.write().await = format!("{host}:{port}");
return;
}
*GLOBAL_Local_Node_Name.write().await = format!("127.0.0.1:{}", port);
*GLOBAL_Local_Node_Name.write().await = format!("127.0.0.1:{port}");
return;
}
@@ -2599,7 +2599,7 @@ fn check_new_multipart_args(bucket: &str, object: &str) -> Result<()> {
fn check_multipart_object_args(bucket: &str, object: &str, upload_id: &str) -> Result<()> {
if let Err(e) = base64_decode(upload_id.as_bytes()) {
return Err(StorageError::MalformedUploadID(format!("{}/{}-{},err:{}", bucket, object, upload_id, e)));
return Err(StorageError::MalformedUploadID(format!("{bucket}/{object}-{upload_id},err:{e}")));
};
check_object_args(bucket, object)
}
+4 -4
View File
@@ -131,7 +131,7 @@ impl GetObjectReader {
let actual_size = if actual_size > 0 {
actual_size as usize
} else {
return Err(Error::other(format!("invalid decompressed size {}", actual_size)));
return Err(Error::other(format!("invalid decompressed size {actual_size}")));
};
let dec_reader = LimitReader::new(dec_reader, actual_size);
@@ -428,13 +428,13 @@ impl Clone for ObjectInfo {
impl ObjectInfo {
pub fn is_compressed(&self) -> bool {
self.user_defined
.contains_key(&format!("{}compression", RESERVED_METADATA_PREFIX_LOWER))
.contains_key(&format!("{RESERVED_METADATA_PREFIX_LOWER}compression"))
}
pub fn is_compressed_ok(&self) -> Result<(CompressionAlgorithm, bool)> {
let scheme = self
.user_defined
.get(&format!("{}compression", RESERVED_METADATA_PREFIX_LOWER))
.get(&format!("{RESERVED_METADATA_PREFIX_LOWER}compression"))
.cloned();
if let Some(scheme) = scheme {
@@ -457,7 +457,7 @@ impl ObjectInfo {
if self.is_compressed() {
if let Some(size_str) = self
.user_defined
.get(&format!("{}actual-size", RESERVED_METADATA_PREFIX_LOWER))
.get(&format!("{RESERVED_METADATA_PREFIX_LOWER}actual-size"))
{
if !size_str.is_empty() {
// Todo: deal with error
+2 -2
View File
@@ -130,7 +130,7 @@ impl ListPathOptions {
pub fn parse_marker(&mut self) {
if let Some(marker) = &self.marker {
let s = marker.clone();
if !s.contains(format!("[rustfs_cache:{}", MARKER_TAG_VERSION).as_str()) {
if !s.contains(format!("[rustfs_cache:{MARKER_TAG_VERSION}").as_str()) {
return;
}
@@ -188,7 +188,7 @@ impl ListPathOptions {
self.pool_idx.unwrap_or_default(),
)
} else {
format!("{}[rustfs_cache:{},return:]", marker, MARKER_TAG_VERSION)
format!("{marker}[rustfs_cache:{MARKER_TAG_VERSION},return:]")
}
}
}