refactor(filemeta): ChecksumInfo hash use Bytes

This commit is contained in:
Nugine
2025-06-15 21:01:38 +08:00
parent 87423bfb8c
commit 3a567768c1
4 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ time.workspace = true
uuid = { workspace = true, features = ["v4", "fast-rng", "serde"] } uuid = { workspace = true, features = ["v4", "fast-rng", "serde"] }
tokio = { workspace = true, features = ["io-util", "macros", "sync"] } tokio = { workspace = true, features = ["io-util", "macros", "sync"] }
xxhash-rust = { version = "0.8.15", features = ["xxh64"] } xxhash-rust = { version = "0.8.15", features = ["xxh64"] }
bytes.workspace = true
rustfs-utils = {workspace = true, features= ["hash"]} rustfs-utils = {workspace = true, features= ["hash"]}
byteorder = "1.5.0" byteorder = "1.5.0"
tracing.workspace = true tracing.workspace = true
+2 -1
View File
@@ -1,5 +1,6 @@
use crate::error::{Error, Result}; use crate::error::{Error, Result};
use crate::headers::RESERVED_METADATA_PREFIX_LOWER; use crate::headers::RESERVED_METADATA_PREFIX_LOWER;
use bytes::Bytes;
use rmp_serde::Serializer; use rmp_serde::Serializer;
use rustfs_utils::HashAlgorithm; use rustfs_utils::HashAlgorithm;
use serde::Deserialize; use serde::Deserialize;
@@ -36,7 +37,7 @@ pub struct ObjectPartInfo {
pub struct ChecksumInfo { pub struct ChecksumInfo {
pub part_number: usize, pub part_number: usize,
pub algorithm: HashAlgorithm, pub algorithm: HashAlgorithm,
pub hash: Vec<u8>, pub hash: Bytes,
} }
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Default, Clone)] #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Default, Clone)]
+1 -1
View File
@@ -703,7 +703,7 @@ impl LocalDisk {
let meta = file.metadata().await.map_err(to_file_error)?; let meta = file.metadata().await.map_err(to_file_error)?;
let file_size = meta.len() as usize; let file_size = meta.len() as usize;
bitrot_verify(Box::new(file), file_size, part_size, algo, sum.to_vec(), shard_size) bitrot_verify(Box::new(file), file_size, part_size, algo, bytes::Bytes::copy_from_slice(sum), shard_size)
.await .await
.map_err(to_file_error)?; .map_err(to_file_error)?;
+2 -1
View File
@@ -1,3 +1,4 @@
use bytes::Bytes;
use pin_project_lite::pin_project; use pin_project_lite::pin_project;
use rustfs_utils::{HashAlgorithm, read_full, write_all}; use rustfs_utils::{HashAlgorithm, read_full, write_all};
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite}; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite};
@@ -174,7 +175,7 @@ pub async fn bitrot_verify<R: AsyncRead + Unpin + Send>(
want_size: usize, want_size: usize,
part_size: usize, part_size: usize,
algo: HashAlgorithm, algo: HashAlgorithm,
_want: Vec<u8>, _want: Bytes, // FIXME: useless parameter?
mut shard_size: usize, mut shard_size: usize,
) -> std::io::Result<()> { ) -> std::io::Result<()> {
let mut hash_buf = vec![0; algo.size()]; let mut hash_buf = vec![0; algo.size()];