mirror of
https://github.com/rustfs/rustfs.git
synced 2026-09-03 02:38:12 +00:00
fix: 优化警告代码
This commit is contained in:
+10
-10
@@ -24,11 +24,11 @@ use uuid::Uuid;
|
|||||||
pub struct LocalDisk {
|
pub struct LocalDisk {
|
||||||
pub root: PathBuf,
|
pub root: PathBuf,
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub format_data: Vec<u8>,
|
pub _format_data: Vec<u8>,
|
||||||
pub format_meta: Option<Metadata>,
|
pub _format_meta: Option<Metadata>,
|
||||||
pub format_path: PathBuf,
|
pub _format_path: PathBuf,
|
||||||
// pub format_legacy: bool, // drop
|
// pub format_legacy: bool, // drop
|
||||||
pub format_last_check: OffsetDateTime,
|
pub _format_last_check: OffsetDateTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LocalDisk {
|
impl LocalDisk {
|
||||||
@@ -67,11 +67,11 @@ impl LocalDisk {
|
|||||||
let disk = Self {
|
let disk = Self {
|
||||||
root,
|
root,
|
||||||
id,
|
id,
|
||||||
format_meta,
|
_format_meta: format_meta,
|
||||||
format_data,
|
_format_data: format_data,
|
||||||
format_path,
|
_format_path: format_path,
|
||||||
// format_legacy,
|
// format_legacy,
|
||||||
format_last_check,
|
_format_last_check: format_last_check,
|
||||||
};
|
};
|
||||||
|
|
||||||
disk.make_meta_volumes().await?;
|
disk.make_meta_volumes().await?;
|
||||||
@@ -463,7 +463,7 @@ impl DiskAPI for LocalDisk {
|
|||||||
|
|
||||||
// Ok((buffer, bytes_read))
|
// Ok((buffer, bytes_read))
|
||||||
}
|
}
|
||||||
async fn list_dir(&self, origvolume: &str, volume: &str, dir_path: &str, count: usize) -> Result<Vec<String>> {
|
async fn list_dir(&self, _origvolume: &str, volume: &str, _dir_path: &str, _count: usize) -> Result<Vec<String>> {
|
||||||
let p = self.get_bucket_path(volume)?;
|
let p = self.get_bucket_path(volume)?;
|
||||||
|
|
||||||
let mut entries = fs::read_dir(&p).await?;
|
let mut entries = fs::read_dir(&p).await?;
|
||||||
@@ -471,7 +471,7 @@ impl DiskAPI for LocalDisk {
|
|||||||
let mut volumes = Vec::new();
|
let mut volumes = Vec::new();
|
||||||
|
|
||||||
while let Some(entry) = entries.next_entry().await? {
|
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() {
|
// if !metadata.is_dir() {
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
|
|||||||
+15
-19
@@ -17,10 +17,10 @@ use crate::disk::FileReader;
|
|||||||
|
|
||||||
pub struct Erasure {
|
pub struct Erasure {
|
||||||
data_shards: usize,
|
data_shards: usize,
|
||||||
parity_shards: usize,
|
_parity_shards: usize,
|
||||||
encoder: ReedSolomon,
|
encoder: ReedSolomon,
|
||||||
block_size: usize,
|
block_size: usize,
|
||||||
id: Uuid,
|
_id: Uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Erasure {
|
impl Erasure {
|
||||||
@@ -31,17 +31,17 @@ impl Erasure {
|
|||||||
);
|
);
|
||||||
Erasure {
|
Erasure {
|
||||||
data_shards,
|
data_shards,
|
||||||
parity_shards,
|
_parity_shards: parity_shards,
|
||||||
block_size,
|
block_size,
|
||||||
encoder: ReedSolomon::new(data_shards, parity_shards).unwrap(),
|
encoder: ReedSolomon::new(data_shards, parity_shards).unwrap(),
|
||||||
id: Uuid::new_v4(),
|
_id: Uuid::new_v4(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn encode<S, W>(
|
pub async fn encode<S, W>(
|
||||||
&self,
|
&self,
|
||||||
body: S,
|
body: S,
|
||||||
writers: &mut Vec<W>,
|
writers: &mut [W],
|
||||||
// block_size: usize,
|
// block_size: usize,
|
||||||
total_size: usize,
|
total_size: usize,
|
||||||
_write_quorum: usize,
|
_write_quorum: usize,
|
||||||
@@ -134,21 +134,16 @@ impl Erasure {
|
|||||||
let mut bytes_writed = 0;
|
let mut bytes_writed = 0;
|
||||||
|
|
||||||
for block_idx in start_block..=end_block {
|
for block_idx in start_block..=end_block {
|
||||||
let mut block_offset = 0;
|
let (block_offset, block_length) = if start_block == end_block {
|
||||||
let mut block_length = 0;
|
(offset % self.block_size, length)
|
||||||
if start_block == end_block {
|
|
||||||
block_offset = offset % self.block_size;
|
|
||||||
block_length = length;
|
|
||||||
} else if block_idx == start_block {
|
} else if block_idx == start_block {
|
||||||
block_offset = offset % self.block_size;
|
let block_offset = offset % self.block_size;
|
||||||
block_length = self.block_size - block_offset;
|
(block_offset, self.block_size - block_offset)
|
||||||
} else if block_idx == end_block {
|
} else if block_idx == end_block {
|
||||||
block_offset = 0;
|
(0, (offset + length) % self.block_size)
|
||||||
block_length = (offset + length) % self.block_size;
|
|
||||||
} else {
|
} else {
|
||||||
block_offset = 0;
|
(0, self.block_size)
|
||||||
block_length = self.block_size;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
if block_length == 0 {
|
if block_length == 0 {
|
||||||
// debug!("block_length == 0 break");
|
// debug!("block_length == 0 break");
|
||||||
@@ -272,7 +267,7 @@ impl Erasure {
|
|||||||
Ok(shards)
|
Ok(shards)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decode_data(&self, shards: &mut Vec<Option<Vec<u8>>>) -> Result<()> {
|
pub fn decode_data(&self, shards: &mut [Option<Vec<u8>>]) -> Result<()> {
|
||||||
self.encoder.reconstruct(shards)?;
|
self.encoder.reconstruct(shards)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -385,7 +380,8 @@ impl ShardReader {
|
|||||||
|
|
||||||
Ok(ress)
|
Ok(ress)
|
||||||
}
|
}
|
||||||
fn can_decode(&self, bufs: &Vec<Option<Vec<u8>>>) -> bool {
|
|
||||||
|
fn can_decode(&self, bufs: &[Option<Vec<u8>>]) -> bool {
|
||||||
bufs.iter().filter(|v| v.is_some()).count() > self.data_block_count
|
bufs.iter().filter(|v| v.is_some()).count() > self.data_block_count
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -202,7 +202,7 @@ impl PeerS3Client for S3PeerSys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ress.iter()
|
ress.iter()
|
||||||
.find_map(|op| op.as_ref().map(|v| v.clone()))
|
.find_map(|op| op.clone())
|
||||||
.ok_or(Error::new(DiskError::VolumeNotFound))
|
.ok_or(Error::new(DiskError::VolumeNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ impl PeerS3Client for LocalPeerS3Client {
|
|||||||
fn get_pools(&self) -> Vec<usize> {
|
fn get_pools(&self) -> Vec<usize> {
|
||||||
self.pools.clone()
|
self.pools.clone()
|
||||||
}
|
}
|
||||||
async fn list_bucket(&self, opts: &BucketOptions) -> Result<Vec<BucketInfo>> {
|
async fn list_bucket(&self, _opts: &BucketOptions) -> Result<Vec<BucketInfo>> {
|
||||||
let mut futures = Vec::with_capacity(self.local_disks.len());
|
let mut futures = Vec::with_capacity(self.local_disks.len());
|
||||||
for disk in self.local_disks.iter() {
|
for disk in self.local_disks.iter() {
|
||||||
futures.push(disk.list_volumes());
|
futures.push(disk.list_volumes());
|
||||||
@@ -390,7 +390,7 @@ impl PeerS3Client for RemotePeerS3Client {
|
|||||||
fn get_pools(&self) -> Vec<usize> {
|
fn get_pools(&self) -> Vec<usize> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
async fn list_bucket(&self, opts: &BucketOptions) -> Result<Vec<BucketInfo>> {
|
async fn list_bucket(&self, _opts: &BucketOptions) -> Result<Vec<BucketInfo>> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
async fn make_bucket(&self, _bucket: &str, _opts: &MakeBucketOptions) -> Result<()> {
|
async fn make_bucket(&self, _bucket: &str, _opts: &MakeBucketOptions) -> Result<()> {
|
||||||
@@ -400,7 +400,7 @@ impl PeerS3Client for RemotePeerS3Client {
|
|||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete_bucket(&self, bucket: &str) -> Result<()> {
|
async fn delete_bucket(&self, _bucket: &str) -> Result<()> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -8,8 +8,8 @@ use crate::{
|
|||||||
error::Result,
|
error::Result,
|
||||||
set_disk::SetDisks,
|
set_disk::SetDisks,
|
||||||
store_api::{
|
store_api::{
|
||||||
BucketInfo, BucketOptions, CompletePart, FileInfo, GetObjectReader, HTTPRangeSpec, MakeBucketOptions,
|
BucketInfo, BucketOptions, CompletePart, GetObjectReader, HTTPRangeSpec, MakeBucketOptions, MultipartUploadResult,
|
||||||
MultipartUploadResult, ObjectInfo, ObjectOptions, PartInfo, PutObjReader, StorageAPI,
|
ObjectInfo, ObjectOptions, PartInfo, PutObjReader, StorageAPI,
|
||||||
},
|
},
|
||||||
utils::hash,
|
utils::hash,
|
||||||
};
|
};
|
||||||
@@ -66,7 +66,7 @@ impl Sets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let sets = Self {
|
let sets = Self {
|
||||||
id: fm.id.clone(),
|
id: fm.id,
|
||||||
// sets: todo!(),
|
// sets: todo!(),
|
||||||
disk_set,
|
disk_set,
|
||||||
pool_idx,
|
pool_idx,
|
||||||
@@ -122,7 +122,7 @@ impl Sets {
|
|||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl StorageAPI for Sets {
|
impl StorageAPI for Sets {
|
||||||
async fn list_bucket(&self, opts: &BucketOptions) -> Result<Vec<BucketInfo>> {
|
async fn list_bucket(&self, _opts: &BucketOptions) -> Result<Vec<BucketInfo>> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
async fn make_bucket(&self, _bucket: &str, _opts: &MakeBucketOptions) -> Result<()> {
|
async fn make_bucket(&self, _bucket: &str, _opts: &MakeBucketOptions) -> Result<()> {
|
||||||
@@ -187,7 +187,7 @@ impl StorageAPI for Sets {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete_bucket(&self, bucket: &str) -> Result<()> {
|
async fn delete_bucket(&self, _bucket: &str) -> Result<()> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ impl ECStore {
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if deployment_id.is_none() {
|
if deployment_id.is_none() {
|
||||||
deployment_id = Some(fm.id.clone());
|
deployment_id = Some(fm.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if deployment_id != Some(fm.id) {
|
if deployment_id != Some(fm.id) {
|
||||||
|
|||||||
+11
-13
@@ -4,8 +4,6 @@ use rmp_serde::Serializer;
|
|||||||
use s3s::dto::StreamingBlob;
|
use s3s::dto::StreamingBlob;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
use tokio::io::{AsyncRead, DuplexStream};
|
|
||||||
use tracing::warn;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
pub const ERASURE_ALGORITHM: &str = "rs-vandermonde";
|
pub const ERASURE_ALGORITHM: &str = "rs-vandermonde";
|
||||||
@@ -56,7 +54,7 @@ impl FileInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn unmarshal(buf: &[u8]) -> Result<Self> {
|
pub fn unmarshal(buf: &[u8]) -> Result<Self> {
|
||||||
let t: FileInfo = rmp_serde::from_slice(&buf)?;
|
let t: FileInfo = rmp_serde::from_slice(buf)?;
|
||||||
Ok(t)
|
Ok(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +78,7 @@ impl FileInfo {
|
|||||||
self.parts.sort_by(|a, b| a.number.cmp(&b.number));
|
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 {
|
ObjectInfo {
|
||||||
bucket: bucket.to_string(),
|
bucket: bucket.to_string(),
|
||||||
name: object.to_string(),
|
name: object.to_string(),
|
||||||
@@ -151,8 +149,8 @@ impl FileInfo {
|
|||||||
Self {
|
Self {
|
||||||
erasure: ErasureInfo {
|
erasure: ErasureInfo {
|
||||||
algorithm: String::from(ERASURE_ALGORITHM),
|
algorithm: String::from(ERASURE_ALGORITHM),
|
||||||
data_blocks: data_blocks,
|
data_blocks,
|
||||||
parity_blocks: parity_blocks,
|
parity_blocks,
|
||||||
block_size: BLOCK_SIZE_V2,
|
block_size: BLOCK_SIZE_V2,
|
||||||
distribution: indexs,
|
distribution: indexs,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@@ -272,7 +270,7 @@ pub struct GetObjectReader {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
pub struct HTTPRangeSpec {
|
pub struct HTTPRangeSpec {
|
||||||
pub is_shuffix_length: bool,
|
pub is_suffix_length: bool,
|
||||||
pub start: i64,
|
pub start: i64,
|
||||||
pub end: i64,
|
pub end: i64,
|
||||||
}
|
}
|
||||||
@@ -280,7 +278,7 @@ pub struct HTTPRangeSpec {
|
|||||||
impl HTTPRangeSpec {
|
impl HTTPRangeSpec {
|
||||||
pub fn nil() -> Self {
|
pub fn nil() -> Self {
|
||||||
Self {
|
Self {
|
||||||
is_shuffix_length: false,
|
is_suffix_length: false,
|
||||||
start: -1,
|
start: -1,
|
||||||
end: -1,
|
end: -1,
|
||||||
}
|
}
|
||||||
@@ -303,9 +301,9 @@ impl HTTPRangeSpec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HTTPRangeSpec {
|
HTTPRangeSpec {
|
||||||
is_shuffix_length: false,
|
is_suffix_length: false,
|
||||||
start: start,
|
start,
|
||||||
end: end,
|
end,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +314,7 @@ impl HTTPRangeSpec {
|
|||||||
|
|
||||||
let len = self.get_length(res_size)?;
|
let len = self.get_length(res_size)?;
|
||||||
let mut start = self.start;
|
let mut start = self.start;
|
||||||
if self.is_shuffix_length {
|
if self.is_suffix_length {
|
||||||
start = self.start + res_size
|
start = self.start + res_size
|
||||||
}
|
}
|
||||||
Ok((start, len))
|
Ok((start, len))
|
||||||
@@ -326,7 +324,7 @@ impl HTTPRangeSpec {
|
|||||||
return Ok(res_size);
|
return Ok(res_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.is_shuffix_length {
|
if self.is_suffix_length {
|
||||||
let specified_len = -self.start; // 假设 h.start 是一个 i64 类型
|
let specified_len = -self.start; // 假设 h.start 是一个 i64 类型
|
||||||
let mut range_length = specified_len;
|
let mut range_length = specified_len;
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ pub fn hex(data: impl AsRef<[u8]>) -> String {
|
|||||||
hex_simd::encode_to_string(data, hex_simd::AsciiCase::Lower)
|
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]> {
|
pub fn sha256(data: &[u8]) -> impl AsRef<[u8; 32]> {
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
<Sha256 as Digest>::digest(data)
|
<Sha256 as Digest>::digest(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "openssl", not(windows)))]
|
#[cfg(not(windows))]
|
||||||
pub fn sha256(data: &[u8]) -> impl AsRef<[u8]> {
|
pub fn sha256(data: &[u8]) -> impl AsRef<[u8]> {
|
||||||
use openssl::hash::{Hasher, MessageDigest};
|
use openssl::hash::{Hasher, MessageDigest};
|
||||||
let mut h = Hasher::new(MessageDigest::sha256()).unwrap();
|
let mut h = Hasher::new(MessageDigest::sha256()).unwrap();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ pub fn encode_dir_object(object: &str) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn decode_dir_object(object: &str) -> String {
|
pub fn decode_dir_object(object: &str) -> String {
|
||||||
if has_suffix(object, GLOBAL_DIR_SUFFIX) {
|
if has_suffix(object, GLOBAL_DIR_SUFFIX) {
|
||||||
format!("{}{}", object.trim_end_matches(GLOBAL_DIR_SUFFIX), SLASH_SEPARATOR)
|
format!("{}{}", object.trim_end_matches(GLOBAL_DIR_SUFFIX), SLASH_SEPARATOR)
|
||||||
|
|||||||
@@ -193,23 +193,7 @@ impl S3 for FS {
|
|||||||
#[tracing::instrument(level = "debug", skip(self, req))]
|
#[tracing::instrument(level = "debug", skip(self, req))]
|
||||||
async fn head_object(&self, req: S3Request<HeadObjectInput>) -> S3Result<S3Response<HeadObjectOutput>> {
|
async fn head_object(&self, req: S3Request<HeadObjectInput>) -> S3Result<S3Response<HeadObjectOutput>> {
|
||||||
// mc get 2
|
// mc get 2
|
||||||
let HeadObjectInput {
|
let HeadObjectInput { bucket, key, .. } = req.input;
|
||||||
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 info = try_!(self.store.get_object_info(&bucket, &key, &ObjectOptions::default()).await);
|
let info = try_!(self.store.get_object_info(&bucket, &key, &ObjectOptions::default()).await);
|
||||||
debug!("info {:?}", info);
|
debug!("info {:?}", info);
|
||||||
@@ -297,7 +281,7 @@ impl S3 for FS {
|
|||||||
|
|
||||||
let Some(content_length) = content_length else { return Err(s3_error!(IncompleteBody)) };
|
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);
|
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))?;
|
let content_length = content_length.ok_or_else(|| s3_error!(IncompleteBody))?;
|
||||||
|
|
||||||
// mc cp step 4
|
// 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();
|
let opts = ObjectOptions::default();
|
||||||
|
|
||||||
try_!(
|
try_!(
|
||||||
@@ -451,6 +435,7 @@ impl S3 for FS {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn bytes_stream<S, E>(stream: S, content_length: usize) -> impl Stream<Item = Result<Bytes, E>> + Send + 'static
|
pub fn bytes_stream<S, E>(stream: S, content_length: usize) -> impl Stream<Item = Result<Bytes, E>> + Send + 'static
|
||||||
where
|
where
|
||||||
S: Stream<Item = Result<Bytes, E>> + Send + 'static,
|
S: Stream<Item = Result<Bytes, E>> + Send + 'static,
|
||||||
|
|||||||
Reference in New Issue
Block a user