mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-28 09:08:58 +00:00
build(toolchain): switch Rust channel to stable (#4775)
* Change Rust toolchain channel to stable Signed-off-by: houseme <housemecn@gmail.com> * style: apply clippy --fix and cargo fix lint suggestions Run `cargo clippy --fix --all-targets --all-features` and `cargo fix --lib --all-targets` across the workspace, then resolve the remaining warnings by hand: - collapse needless borrows in `format!` args, prefer `?` over explicit early returns, and use `.values()` / `.flatten()` iterator adapters - rewrite the `Md5` scan loop via `manual_flatten` and re-indent the `select!` macro body (rustfmt skips macro interiors) - annotate the intentional dead-code `Md5` inherent methods (constructed only by the test factory) with `#[allow(dead_code)]` Behavior is unchanged. Co-Authored-By: heihutu <heihutu@gmail.com> --------- Signed-off-by: houseme <housemecn@gmail.com> Co-authored-by: heihutu <heihutu@gmail.com>
This commit is contained in:
@@ -2312,7 +2312,7 @@ pub fn gen_transition_objname(bucket: &str) -> Result<String, Error> {
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(format!("{}/{}", runtime_sources::deployment_id().unwrap_or_default(), bucket).as_bytes());
|
||||
let hash = rustfs_utils::crypto::hex(hasher.finalize().as_slice());
|
||||
let obj = format!("{}/{}/{}/{}", &hash[0..16], &us[0..2], &us[2..4], &us);
|
||||
let obj = format!("{}/{}/{}/{}", &hash[0..16], &us[0..2], &us[2..4], us);
|
||||
Ok(obj)
|
||||
}
|
||||
|
||||
|
||||
@@ -250,10 +250,9 @@ pub async fn check_object_lock_for_deletion(
|
||||
let now = objectlock::utc_now_ntp();
|
||||
let retain_until = if let Some(days) = default_retention.days {
|
||||
mod_time.saturating_add(time::Duration::days(days as i64))
|
||||
} else if let Some(years) = default_retention.years {
|
||||
add_years(mod_time, years)
|
||||
} else {
|
||||
return None; // No retention period specified
|
||||
let years = default_retention.years?;
|
||||
add_years(mod_time, years)
|
||||
};
|
||||
|
||||
if retain_until.unix_timestamp() > now.unix_timestamp()
|
||||
|
||||
@@ -1405,7 +1405,7 @@ pub(crate) async fn schedule_replication_delete(dv: DeletedObjectReplicationInfo
|
||||
}
|
||||
|
||||
if let (Some(rs), Some(stats)) = (dv.delete_object.replication_state, runtime_sources::replication_stats()) {
|
||||
for (k, _v) in rs.targets.iter() {
|
||||
for k in rs.targets.keys() {
|
||||
let ri = ReplicatedTargetInfo {
|
||||
arn: k.clone(),
|
||||
size: 0,
|
||||
|
||||
@@ -1348,7 +1348,7 @@ pub async fn replicate_delete<S: ReplicationStorage>(dobj: DeletedObjectReplicat
|
||||
let mut join_set = JoinSet::new();
|
||||
|
||||
// Process each target
|
||||
for (_, tgt_entry) in dsc.targets_map.iter() {
|
||||
for tgt_entry in dsc.targets_map.values() {
|
||||
// Skip targets that should not be replicated
|
||||
if !tgt_entry.replicate {
|
||||
continue;
|
||||
|
||||
@@ -208,7 +208,7 @@ impl ReplicationStats {
|
||||
let now = SystemTime::now();
|
||||
|
||||
let cache_read = cache.read().await;
|
||||
for (_bucket, stats) in cache_read.iter() {
|
||||
for stats in cache_read.values() {
|
||||
for stat in stats.stats.values() {
|
||||
// Now we can update the moving averages using interior mutability
|
||||
stat.xfer_rate_lrg.measure.update_exponential_moving_average(now);
|
||||
|
||||
@@ -1203,7 +1203,7 @@ pub async fn save_data_usage_cache(cache: &DataUsageCache, name: &str) -> crate:
|
||||
|
||||
let name_clone = name.clone();
|
||||
tokio::spawn(async move {
|
||||
let _ = save_config(store_clone, &format!("{}{}", &name_clone, ".bkp"), buf_clone).await;
|
||||
let _ = save_config(store_clone, &format!("{}{}", name_clone, ".bkp"), buf_clone).await;
|
||||
});
|
||||
save_config(store, &name, buf).await?;
|
||||
Ok(())
|
||||
|
||||
@@ -5135,12 +5135,11 @@ impl LocalDisk {
|
||||
}
|
||||
|
||||
let metadata =
|
||||
with_walk_stall_timeout(stall, self.read_metadata(bucket, format!("{}/{}", ¤t, &entry).as_str()))
|
||||
.await?;
|
||||
with_walk_stall_timeout(stall, self.read_metadata(bucket, format!("{}/{}", current, entry).as_str())).await?;
|
||||
|
||||
let entry = entry.strip_suffix(STORAGE_FORMAT_FILE).unwrap_or_default().to_owned();
|
||||
let name = entry.trim_end_matches(SLASH_SEPARATOR);
|
||||
let name = decode_dir_object(format!("{}/{}", ¤t, &name).as_str());
|
||||
let name = decode_dir_object(format!("{}/{}", current, name).as_str());
|
||||
|
||||
if opts.limit <= 0 || metadata_counts_toward_limit(&metadata) {
|
||||
*objs_returned += 1;
|
||||
@@ -5252,7 +5251,7 @@ impl LocalDisk {
|
||||
meta.name.push_str(GLOBAL_DIR_SUFFIX_WITH_SLASH);
|
||||
}
|
||||
|
||||
let fname = format!("{}/{}", &meta.name, STORAGE_FORMAT_FILE);
|
||||
let fname = format!("{}/{}", meta.name, STORAGE_FORMAT_FILE);
|
||||
|
||||
match with_walk_stall_timeout(stall, self.read_metadata(&opts.bucket, fname.as_str())).await {
|
||||
Ok(res) => {
|
||||
@@ -6647,8 +6646,8 @@ impl DiskAPI for LocalDisk {
|
||||
}
|
||||
|
||||
// xl.meta path
|
||||
let src_file_path = self.get_object_path(src_volume, format!("{}/{}", &src_path, STORAGE_FORMAT_FILE).as_str())?;
|
||||
let dst_file_path = self.get_object_path(dst_volume, format!("{}/{}", &dst_path, STORAGE_FORMAT_FILE).as_str())?;
|
||||
let src_file_path = self.get_object_path(src_volume, format!("{}/{}", src_path, STORAGE_FORMAT_FILE).as_str())?;
|
||||
let dst_file_path = self.get_object_path(dst_volume, format!("{}/{}", dst_path, STORAGE_FORMAT_FILE).as_str())?;
|
||||
|
||||
// data_dir path
|
||||
let has_data_dir_path = {
|
||||
@@ -6664,11 +6663,11 @@ impl DiskAPI for LocalDisk {
|
||||
if let Some(data_dir) = has_data_dir {
|
||||
let src_data_path = self.get_object_path(
|
||||
src_volume,
|
||||
rustfs_utils::path::retain_slash(format!("{}/{}", &src_path, data_dir).as_str()).as_str(),
|
||||
rustfs_utils::path::retain_slash(format!("{}/{}", src_path, data_dir).as_str()).as_str(),
|
||||
)?;
|
||||
let dst_data_path = self.get_object_path(
|
||||
dst_volume,
|
||||
rustfs_utils::path::retain_slash(format!("{}/{}", &dst_path, data_dir).as_str()).as_str(),
|
||||
rustfs_utils::path::retain_slash(format!("{}/{}", dst_path, data_dir).as_str()).as_str(),
|
||||
)?;
|
||||
|
||||
Some((src_data_path, dst_data_path))
|
||||
@@ -6776,7 +6775,7 @@ impl DiskAPI for LocalDisk {
|
||||
// rename below to report through the existing rollback path. Payload
|
||||
// durability is kept by both strict and relaxed.
|
||||
// Bound to a local so the borrow lives across the join! below.
|
||||
let tmp_meta_rel_path = format!("{}/{}", &src_path, STORAGE_FORMAT_FILE);
|
||||
let tmp_meta_rel_path = format!("{}/{}", src_path, STORAGE_FORMAT_FILE);
|
||||
let tmp_meta_write =
|
||||
self.write_all_private(src_volume, &tmp_meta_rel_path, new_dst_buf.into(), tmp_meta_sync, src_file_parent);
|
||||
let shard_sync = async {
|
||||
@@ -6850,7 +6849,7 @@ impl DiskAPI for LocalDisk {
|
||||
&& let Err(err) = self
|
||||
.write_all_private(
|
||||
dst_volume,
|
||||
&format!("{}/{}/{}", &dst_path, &old_data_dir, STORAGE_FORMAT_FILE_BACKUP),
|
||||
&format!("{}/{}/{}", dst_path, old_data_dir, STORAGE_FORMAT_FILE_BACKUP),
|
||||
dst_buf.clone().into(),
|
||||
backup_sync,
|
||||
&skip_parent,
|
||||
@@ -7326,7 +7325,7 @@ impl DiskAPI for LocalDisk {
|
||||
check_path_length(file_path.to_string_lossy().as_ref())?;
|
||||
|
||||
let buf = self
|
||||
.read_all(volume, format!("{}/{}", &path, STORAGE_FORMAT_FILE).as_str())
|
||||
.read_all(volume, format!("{}/{}", path, STORAGE_FORMAT_FILE).as_str())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
if e == DiskError::FileNotFound && fi.version_id.is_some() {
|
||||
@@ -7750,7 +7749,7 @@ impl DiskAPI for LocalDisk {
|
||||
let mut found = 0;
|
||||
|
||||
for v in req.files.iter() {
|
||||
let fpath = self.get_object_path(&req.bucket, format!("{}/{}", &req.prefix, v).as_str())?;
|
||||
let fpath = self.get_object_path(&req.bucket, format!("{}/{}", req.prefix, v).as_str())?;
|
||||
let mut res = ReadMultipleResp {
|
||||
bucket: req.bucket.clone(),
|
||||
prefix: req.prefix.clone(),
|
||||
@@ -12389,7 +12388,7 @@ mod test {
|
||||
.resolve_abs_path(Path::new(RUSTFS_META_TMP_DELETED_BUCKET))
|
||||
.expect("operation should succeed");
|
||||
|
||||
println!("ppp :{:?}", &tmpp);
|
||||
println!("ppp :{:?}", tmpp);
|
||||
|
||||
let volumes = vec!["a123", "b123", "c123"];
|
||||
|
||||
@@ -12413,7 +12412,7 @@ mod test {
|
||||
.resolve_abs_path(Path::new(RUSTFS_META_TMP_DELETED_BUCKET))
|
||||
.expect("operation should succeed");
|
||||
|
||||
println!("ppp :{:?}", &tmpp);
|
||||
println!("ppp :{:?}", tmpp);
|
||||
|
||||
let volumes = vec!["a123", "b123", "c123"];
|
||||
|
||||
|
||||
@@ -423,7 +423,7 @@ fn get_set_indexes<T: AsRef<str>>(
|
||||
if !has_set_drive_count {
|
||||
return Err(Error::other(format!(
|
||||
"Invalid set drive count {}. Acceptable values for {:?} number drives are {:?}",
|
||||
set_drive_count, common_size, &set_counts
|
||||
set_drive_count, common_size, set_counts
|
||||
)));
|
||||
}
|
||||
set_drive_count
|
||||
@@ -432,7 +432,7 @@ fn get_set_indexes<T: AsRef<str>>(
|
||||
if set_counts.is_empty() {
|
||||
return Err(Error::other(format!(
|
||||
"No symmetric distribution detected with input endpoints , drives {} cannot be spread symmetrically by any supported erasure set sizes {:?}",
|
||||
common_size, &set_counts
|
||||
common_size, set_counts
|
||||
)));
|
||||
}
|
||||
// Final set size with all the symmetry accounted for.
|
||||
|
||||
@@ -2209,7 +2209,7 @@ mod test {
|
||||
if Some(&pools.setup_type) != test_case.expected_setup_type.as_ref() {
|
||||
panic!(
|
||||
"Test {}: setupType: expected = {:?}, got = {:?}",
|
||||
test_case.num, test_case.expected_setup_type, &pools.setup_type
|
||||
test_case.num, test_case.expected_setup_type, pools.setup_type
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ impl SetDisks {
|
||||
}
|
||||
|
||||
if !latest_meta.deleted && !latest_meta.is_remote() {
|
||||
for (_, part_errs) in data_errs_by_part.iter() {
|
||||
for part_errs in data_errs_by_part.values() {
|
||||
if count_part_not_success(part_errs) > latest_meta.erasure.parity_blocks {
|
||||
cannot_heal = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user