mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-11 07:36:53 +00:00
fix:Apply suggestions from clippy 1.88
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
|
||||
@@ -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:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user