diff --git a/ecstore/src/disk/local.rs b/ecstore/src/disk/local.rs index 4c4a2714f..f74076170 100644 --- a/ecstore/src/disk/local.rs +++ b/ecstore/src/disk/local.rs @@ -24,11 +24,11 @@ use uuid::Uuid; pub struct LocalDisk { pub root: PathBuf, pub id: Uuid, - pub format_data: Vec, - pub format_meta: Option, - pub format_path: PathBuf, + pub _format_data: Vec, + pub _format_meta: Option, + pub _format_path: PathBuf, // pub format_legacy: bool, // drop - pub format_last_check: OffsetDateTime, + pub _format_last_check: OffsetDateTime, } impl LocalDisk { @@ -67,11 +67,11 @@ impl LocalDisk { let disk = Self { root, id, - format_meta, - format_data, - format_path, + _format_meta: format_meta, + _format_data: format_data, + _format_path: format_path, // format_legacy, - format_last_check, + _format_last_check: format_last_check, }; disk.make_meta_volumes().await?; @@ -463,7 +463,7 @@ impl DiskAPI for LocalDisk { // Ok((buffer, bytes_read)) } - async fn list_dir(&self, origvolume: &str, volume: &str, dir_path: &str, count: usize) -> Result> { + async fn list_dir(&self, _origvolume: &str, volume: &str, _dir_path: &str, _count: usize) -> Result> { let p = self.get_bucket_path(volume)?; let mut entries = fs::read_dir(&p).await?; @@ -471,7 +471,7 @@ impl DiskAPI for LocalDisk { let mut volumes = Vec::new(); while let Some(entry) = entries.next_entry().await? { - if let Ok(metadata) = entry.metadata().await { + if let Ok(_metadata) = entry.metadata().await { // if !metadata.is_dir() { // continue; // } diff --git a/ecstore/src/erasure.rs b/ecstore/src/erasure.rs index bf4ab739b..82b68a4de 100644 --- a/ecstore/src/erasure.rs +++ b/ecstore/src/erasure.rs @@ -17,10 +17,10 @@ use crate::disk::FileReader; pub struct Erasure { data_shards: usize, - parity_shards: usize, + _parity_shards: usize, encoder: ReedSolomon, block_size: usize, - id: Uuid, + _id: Uuid, } impl Erasure { @@ -31,17 +31,17 @@ impl Erasure { ); Erasure { data_shards, - parity_shards, + _parity_shards: parity_shards, block_size, encoder: ReedSolomon::new(data_shards, parity_shards).unwrap(), - id: Uuid::new_v4(), + _id: Uuid::new_v4(), } } pub async fn encode( &self, body: S, - writers: &mut Vec, + writers: &mut [W], // block_size: usize, total_size: usize, _write_quorum: usize, @@ -134,21 +134,16 @@ impl Erasure { let mut bytes_writed = 0; for block_idx in start_block..=end_block { - let mut block_offset = 0; - let mut block_length = 0; - if start_block == end_block { - block_offset = offset % self.block_size; - block_length = length; + let (block_offset, block_length) = if start_block == end_block { + (offset % self.block_size, length) } else if block_idx == start_block { - block_offset = offset % self.block_size; - block_length = self.block_size - block_offset; + let block_offset = offset % self.block_size; + (block_offset, self.block_size - block_offset) } else if block_idx == end_block { - block_offset = 0; - block_length = (offset + length) % self.block_size; + (0, (offset + length) % self.block_size) } else { - block_offset = 0; - block_length = self.block_size; - } + (0, self.block_size) + }; if block_length == 0 { // debug!("block_length == 0 break"); @@ -272,7 +267,7 @@ impl Erasure { Ok(shards) } - pub fn decode_data(&self, shards: &mut Vec>>) -> Result<()> { + pub fn decode_data(&self, shards: &mut [Option>]) -> Result<()> { self.encoder.reconstruct(shards)?; Ok(()) } @@ -385,7 +380,8 @@ impl ShardReader { Ok(ress) } - fn can_decode(&self, bufs: &Vec>>) -> bool { + + fn can_decode(&self, bufs: &[Option>]) -> bool { bufs.iter().filter(|v| v.is_some()).count() > self.data_block_count } } diff --git a/ecstore/src/peer.rs b/ecstore/src/peer.rs index 4d2e582de..4d7a3039d 100644 --- a/ecstore/src/peer.rs +++ b/ecstore/src/peer.rs @@ -202,7 +202,7 @@ impl PeerS3Client for S3PeerSys { } ress.iter() - .find_map(|op| op.as_ref().map(|v| v.clone())) + .find_map(|op| op.clone()) .ok_or(Error::new(DiskError::VolumeNotFound)) } @@ -233,7 +233,7 @@ impl PeerS3Client for LocalPeerS3Client { fn get_pools(&self) -> Vec { self.pools.clone() } - async fn list_bucket(&self, opts: &BucketOptions) -> Result> { + async fn list_bucket(&self, _opts: &BucketOptions) -> Result> { let mut futures = Vec::with_capacity(self.local_disks.len()); for disk in self.local_disks.iter() { futures.push(disk.list_volumes()); @@ -390,7 +390,7 @@ impl PeerS3Client for RemotePeerS3Client { fn get_pools(&self) -> Vec { unimplemented!() } - async fn list_bucket(&self, opts: &BucketOptions) -> Result> { + async fn list_bucket(&self, _opts: &BucketOptions) -> Result> { unimplemented!() } async fn make_bucket(&self, _bucket: &str, _opts: &MakeBucketOptions) -> Result<()> { @@ -400,7 +400,7 @@ impl PeerS3Client for RemotePeerS3Client { unimplemented!() } - async fn delete_bucket(&self, bucket: &str) -> Result<()> { + async fn delete_bucket(&self, _bucket: &str) -> Result<()> { unimplemented!() } } diff --git a/ecstore/src/sets.rs b/ecstore/src/sets.rs index bf8546234..7f606a612 100644 --- a/ecstore/src/sets.rs +++ b/ecstore/src/sets.rs @@ -8,8 +8,8 @@ use crate::{ error::Result, set_disk::SetDisks, store_api::{ - BucketInfo, BucketOptions, CompletePart, FileInfo, GetObjectReader, HTTPRangeSpec, MakeBucketOptions, - MultipartUploadResult, ObjectInfo, ObjectOptions, PartInfo, PutObjReader, StorageAPI, + BucketInfo, BucketOptions, CompletePart, GetObjectReader, HTTPRangeSpec, MakeBucketOptions, MultipartUploadResult, + ObjectInfo, ObjectOptions, PartInfo, PutObjReader, StorageAPI, }, utils::hash, }; @@ -66,7 +66,7 @@ impl Sets { } let sets = Self { - id: fm.id.clone(), + id: fm.id, // sets: todo!(), disk_set, pool_idx, @@ -122,7 +122,7 @@ impl Sets { #[async_trait::async_trait] impl StorageAPI for Sets { - async fn list_bucket(&self, opts: &BucketOptions) -> Result> { + async fn list_bucket(&self, _opts: &BucketOptions) -> Result> { unimplemented!() } async fn make_bucket(&self, _bucket: &str, _opts: &MakeBucketOptions) -> Result<()> { @@ -187,7 +187,7 @@ impl StorageAPI for Sets { .await } - async fn delete_bucket(&self, bucket: &str) -> Result<()> { + async fn delete_bucket(&self, _bucket: &str) -> Result<()> { unimplemented!() } } diff --git a/ecstore/src/store.rs b/ecstore/src/store.rs index cf86481a4..92ff6ebd6 100644 --- a/ecstore/src/store.rs +++ b/ecstore/src/store.rs @@ -68,7 +68,7 @@ impl ECStore { .await?; if deployment_id.is_none() { - deployment_id = Some(fm.id.clone()); + deployment_id = Some(fm.id); } if deployment_id != Some(fm.id) { diff --git a/ecstore/src/store_api.rs b/ecstore/src/store_api.rs index f407f3210..b601a66b0 100644 --- a/ecstore/src/store_api.rs +++ b/ecstore/src/store_api.rs @@ -4,8 +4,6 @@ use rmp_serde::Serializer; use s3s::dto::StreamingBlob; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; -use tokio::io::{AsyncRead, DuplexStream}; -use tracing::warn; use uuid::Uuid; pub const ERASURE_ALGORITHM: &str = "rs-vandermonde"; @@ -56,7 +54,7 @@ impl FileInfo { } pub fn unmarshal(buf: &[u8]) -> Result { - let t: FileInfo = rmp_serde::from_slice(&buf)?; + let t: FileInfo = rmp_serde::from_slice(buf)?; Ok(t) } @@ -80,7 +78,7 @@ impl FileInfo { self.parts.sort_by(|a, b| a.number.cmp(&b.number)); } - pub fn into_object_info(&self, bucket: &str, object: &str, versioned: bool) -> ObjectInfo { + pub fn into_object_info(&self, bucket: &str, object: &str, _versioned: bool) -> ObjectInfo { ObjectInfo { bucket: bucket.to_string(), name: object.to_string(), @@ -151,8 +149,8 @@ impl FileInfo { Self { erasure: ErasureInfo { algorithm: String::from(ERASURE_ALGORITHM), - data_blocks: data_blocks, - parity_blocks: parity_blocks, + data_blocks, + parity_blocks, block_size: BLOCK_SIZE_V2, distribution: indexs, ..Default::default() @@ -272,7 +270,7 @@ pub struct GetObjectReader { // } pub struct HTTPRangeSpec { - pub is_shuffix_length: bool, + pub is_suffix_length: bool, pub start: i64, pub end: i64, } @@ -280,7 +278,7 @@ pub struct HTTPRangeSpec { impl HTTPRangeSpec { pub fn nil() -> Self { Self { - is_shuffix_length: false, + is_suffix_length: false, start: -1, end: -1, } @@ -303,9 +301,9 @@ impl HTTPRangeSpec { } HTTPRangeSpec { - is_shuffix_length: false, - start: start, - end: end, + is_suffix_length: false, + start, + end, } } @@ -316,7 +314,7 @@ impl HTTPRangeSpec { let len = self.get_length(res_size)?; let mut start = self.start; - if self.is_shuffix_length { + if self.is_suffix_length { start = self.start + res_size } Ok((start, len)) @@ -326,7 +324,7 @@ impl HTTPRangeSpec { return Ok(res_size); } - if self.is_shuffix_length { + if self.is_suffix_length { let specified_len = -self.start; // 假设 h.start 是一个 i64 类型 let mut range_length = specified_len; diff --git a/ecstore/src/utils/crypto.rs b/ecstore/src/utils/crypto.rs index 5a7f86b31..35495315c 100644 --- a/ecstore/src/utils/crypto.rs +++ b/ecstore/src/utils/crypto.rs @@ -10,13 +10,13 @@ pub fn hex(data: impl AsRef<[u8]>) -> String { hex_simd::encode_to_string(data, hex_simd::AsciiCase::Lower) } -#[cfg(not(all(feature = "openssl", not(windows))))] +#[cfg(windows)] pub fn sha256(data: &[u8]) -> impl AsRef<[u8; 32]> { use sha2::{Digest, Sha256}; ::digest(data) } -#[cfg(all(feature = "openssl", not(windows)))] +#[cfg(not(windows))] pub fn sha256(data: &[u8]) -> impl AsRef<[u8]> { use openssl::hash::{Hasher, MessageDigest}; let mut h = Hasher::new(MessageDigest::sha256()).unwrap(); diff --git a/ecstore/src/utils/path.rs b/ecstore/src/utils/path.rs index ab93e9499..0f799b41e 100644 --- a/ecstore/src/utils/path.rs +++ b/ecstore/src/utils/path.rs @@ -18,6 +18,7 @@ pub fn encode_dir_object(object: &str) -> String { } } +#[allow(dead_code)] pub fn decode_dir_object(object: &str) -> String { if has_suffix(object, GLOBAL_DIR_SUFFIX) { format!("{}{}", object.trim_end_matches(GLOBAL_DIR_SUFFIX), SLASH_SEPARATOR) diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index ff9df3e4c..d860ab312 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -193,23 +193,7 @@ impl S3 for FS { #[tracing::instrument(level = "debug", skip(self, req))] async fn head_object(&self, req: S3Request) -> S3Result> { // mc get 2 - let HeadObjectInput { - bucket, - checksum_mode, - expected_bucket_owner, - if_match, - if_modified_since, - if_none_match, - if_unmodified_since, - key, - part_number, - range, - request_payer, - sse_customer_algorithm, - sse_customer_key, - sse_customer_key_md5, - version_id, - } = req.input; + let HeadObjectInput { bucket, key, .. } = req.input; let info = try_!(self.store.get_object_info(&bucket, &key, &ObjectOptions::default()).await); debug!("info {:?}", info); @@ -297,7 +281,7 @@ impl S3 for FS { let Some(content_length) = content_length else { return Err(s3_error!(IncompleteBody)) }; - let reader = PutObjReader::new(body.into(), content_length as usize); + let reader = PutObjReader::new(body, content_length as usize); try_!(self.store.put_object(&bucket, &key, reader, &ObjectOptions::default()).await); @@ -356,7 +340,7 @@ impl S3 for FS { let content_length = content_length.ok_or_else(|| s3_error!(IncompleteBody))?; // mc cp step 4 - let data = PutObjReader::new(body.into(), content_length as usize); + let data = PutObjReader::new(body, content_length as usize); let opts = ObjectOptions::default(); try_!( @@ -451,6 +435,7 @@ impl S3 for FS { } } +#[allow(dead_code)] pub fn bytes_stream(stream: S, content_length: usize) -> impl Stream> + Send + 'static where S: Stream> + Send + 'static,