mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 15:37:02 +00:00
feat: Add RustFS Scanner Module and Multiple Bug Fixes (#1579)
This commit is contained in:
@@ -169,12 +169,31 @@ impl ErasureInfo {
|
||||
|
||||
/// Check if this ErasureInfo equals another ErasureInfo
|
||||
pub fn equals(&self, other: &ErasureInfo) -> bool {
|
||||
self.algorithm == other.algorithm
|
||||
&& self.data_blocks == other.data_blocks
|
||||
&& self.parity_blocks == other.parity_blocks
|
||||
&& self.block_size == other.block_size
|
||||
&& self.index == other.index
|
||||
&& self.distribution == other.distribution
|
||||
if self.algorithm != other.algorithm {
|
||||
return false;
|
||||
}
|
||||
|
||||
if self.data_blocks != other.data_blocks {
|
||||
return false;
|
||||
}
|
||||
|
||||
if self.parity_blocks != other.parity_blocks {
|
||||
return false;
|
||||
}
|
||||
|
||||
if self.block_size != other.block_size {
|
||||
return false;
|
||||
}
|
||||
|
||||
if self.distribution.len() != other.distribution.len() {
|
||||
return false;
|
||||
}
|
||||
for (i, v) in self.distribution.iter().enumerate() {
|
||||
if v != &other.distribution[i] {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,21 +457,28 @@ impl FileInfo {
|
||||
pub fn equals(&self, other: &FileInfo) -> bool {
|
||||
// Check if both are compressed or both are not compressed
|
||||
if self.is_compressed() != other.is_compressed() {
|
||||
tracing::warn!("equals: is_compressed is not equal, object_name={}", self.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check transition info
|
||||
if !self.transition_info_equals(other) {
|
||||
tracing::warn!("equals: transition_info_equals is not equal, object_name={}", self.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check mod time
|
||||
if self.mod_time != other.mod_time {
|
||||
tracing::warn!("equals: mod_time is not equal, object_name={}", self.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check erasure info
|
||||
self.erasure.equals(&other.erasure)
|
||||
if !self.erasure.equals(&other.erasure) {
|
||||
tracing::warn!("equals: erasure is not equal, object_name={}", self.name);
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
/// Check if transition related information are equal
|
||||
|
||||
@@ -1005,6 +1005,41 @@ impl FileMeta {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_file_info_versions(&self, volume: &str, path: &str, include_free_versions: bool) -> Result<FileInfoVersions> {
|
||||
let mut versions = self.into_file_info_versions(volume, path, true)?;
|
||||
|
||||
let mut n = 0;
|
||||
|
||||
let mut versions_vec = Vec::new();
|
||||
|
||||
for fi in versions.versions.iter() {
|
||||
if fi.tier_free_version() {
|
||||
if !include_free_versions {
|
||||
versions.free_versions.push(fi.clone());
|
||||
}
|
||||
} else {
|
||||
if !include_free_versions {
|
||||
versions_vec.push(fi.clone());
|
||||
}
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if !include_free_versions {
|
||||
versions.versions = versions_vec;
|
||||
}
|
||||
|
||||
for fi in versions.free_versions.iter_mut() {
|
||||
fi.num_versions = n;
|
||||
}
|
||||
|
||||
Ok(versions)
|
||||
}
|
||||
|
||||
pub fn get_all_file_info_versions(&self, volume: &str, path: &str, all_parts: bool) -> Result<FileInfoVersions> {
|
||||
self.into_file_info_versions(volume, path, all_parts)
|
||||
}
|
||||
|
||||
pub fn into_file_info_versions(&self, volume: &str, path: &str, all_parts: bool) -> Result<FileInfoVersions> {
|
||||
let mut versions = Vec::new();
|
||||
for version in self.versions.iter() {
|
||||
|
||||
@@ -708,7 +708,7 @@ pub fn parse_replicate_decision(_bucket: &str, s: &str) -> std::io::Result<Repli
|
||||
// }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
pub struct ReplicateObjectInfo {
|
||||
pub name: String,
|
||||
pub size: i64,
|
||||
|
||||
Reference in New Issue
Block a user