fix: #23 need test reduce_read_quorum_errs

This commit is contained in:
weisd
2024-09-24 16:21:02 +08:00
parent 3686afafc0
commit 47182c0544
7 changed files with 36 additions and 29 deletions

View File

@@ -113,9 +113,9 @@ impl LocalDisk {
Ok(disk)
}
fn check_path_length(path_name: &str) -> Result<()> {
unimplemented!()
}
// fn check_path_length(_path_name: &str) -> Result<()> {
// unimplemented!()
// }
fn is_valid_volname(volname: &str) -> bool {
if volname.len() < 3 {
@@ -1000,10 +1000,10 @@ impl DiskAPI for LocalDisk {
created: modtime,
})
}
async fn delete_paths(&self, volume: &str, paths: &[&str]) -> Result<()> {
async fn delete_paths(&self, _volume: &str, _paths: &[&str]) -> Result<()> {
unimplemented!()
}
async fn update_metadata(&self, volume: &str, path: &str, fi: FileInfo, opts: UpdateMetadataOpts) {
async fn update_metadata(&self, _volume: &str, _path: &str, _fi: FileInfo, _opts: UpdateMetadataOpts) {
unimplemented!()
}
async fn write_metadata(&self, _org_volume: &str, volume: &str, path: &str, fi: FileInfo) -> Result<()> {
@@ -1062,11 +1062,11 @@ impl DiskAPI for LocalDisk {
}
async fn delete_version(
&self,
volume: &str,
path: &str,
fi: FileInfo,
force_del_marker: bool,
opts: DeleteOptions,
_volume: &str,
_path: &str,
_fi: FileInfo,
_force_del_marker: bool,
_opts: DeleteOptions,
) -> Result<RawFileInfo> {
unimplemented!()
}

View File

@@ -482,11 +482,11 @@ impl DiskAPI for RemoteDisk {
}
async fn delete_version(
&self,
volume: &str,
path: &str,
fi: FileInfo,
force_del_marker: bool,
opts: DeleteOptions,
_volume: &str,
_path: &str,
_fi: FileInfo,
_force_del_marker: bool,
_opts: DeleteOptions,
) -> Result<RawFileInfo> {
unimplemented!()
}

View File

@@ -1,7 +1,4 @@
use crate::{
disk::error::DiskError,
error::{Error, Result},
};
use crate::{disk::error::DiskError, error::Error};
use std::{collections::HashMap, fmt::Debug};
// pub type CheckErrorFn = fn(e: &Error) -> bool;
@@ -11,7 +8,7 @@ pub trait CheckErrorFn: Debug + Send + Sync + 'static {
}
#[derive(Debug, thiserror::Error)]
enum QuorumError {
pub enum QuorumError {
#[error("Read quorum not met")]
Read,
#[error("disk not found")]
@@ -112,7 +109,7 @@ fn reduce_quorum_errs(
// 根据读quorum验证错误数量
// 返回最大错误数量的下标或QuorumError
pub fn reduce_read_quorum_errs(
errs: &mut Vec<Option<Error>>,
errs: &Vec<Option<Error>>,
ignored_errs: &Vec<Box<dyn CheckErrorFn>>,
read_quorum: usize,
) -> Option<Error> {

View File

@@ -98,7 +98,7 @@ impl Sets {
let set_disks = SetDisks {
disks: RwLock::new(set_drive),
set_drive_count,
parity_count: partiy_count,
default_parity_count: partiy_count,
set_index: i,
pool_index: pool_idx,
set_endpoints,
@@ -343,7 +343,7 @@ impl StorageAPI for Sets {
.get_object_reader(bucket, object, range, h, opts)
.await
}
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<()> {
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<ObjectInfo> {
self.get_disks_by_key(object).put_object(bucket, object, data, opts).await
}

View File

@@ -314,7 +314,7 @@ impl ECStore {
if entry.is_object() {
let fi = entry.to_fileinfo(&opts.bucket)?;
if fi.is_some() {
ress.push(fi.unwrap().into_object_info(&opts.bucket, &entry.name, false));
ress.push(fi.unwrap().to_object_info(&opts.bucket, &entry.name, false));
}
continue;
}
@@ -738,7 +738,7 @@ impl StorageAPI for ECStore {
unimplemented!()
}
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<()> {
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<ObjectInfo> {
// checkPutObjectArgs
let object = utils::path::encode_dir_object(object);

View File

@@ -29,6 +29,8 @@ pub struct FileInfo {
pub is_latest: bool,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub tags: Option<HashMap<String, String>>,
pub metadata: Option<HashMap<String, String>>,
pub num_versions: usize,
}
// impl Default for FileInfo {
@@ -96,6 +98,14 @@ impl FileInfo {
false
}
pub fn get_etag(&self) -> Option<String> {
if let Some(meta) = &self.metadata {
meta.get("etag").cloned()
} else {
None
}
}
pub fn write_quorum(&self, quorum: usize) -> usize {
if self.deleted {
return quorum;
@@ -141,7 +151,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 to_object_info(&self, bucket: &str, object: &str, _versioned: bool) -> ObjectInfo {
ObjectInfo {
bucket: bucket.to_string(),
name: object.to_string(),
@@ -533,7 +543,7 @@ pub trait StorageAPI {
h: HeaderMap,
opts: &ObjectOptions,
) -> Result<GetObjectReader>;
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<()>;
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<ObjectInfo>;
async fn put_object_part(
&self,
bucket: &str,

View File

@@ -2,7 +2,7 @@ use std::{fs::Metadata, path::Path};
use tokio::{fs, io};
#[cfg(not(target_os = "windows"))]
#[cfg(not(windows))]
pub fn same_file(f1: &Metadata, f2: &Metadata) -> bool {
use std::os::unix::fs::MetadataExt;
@@ -28,7 +28,7 @@ pub fn same_file(f1: &Metadata, f2: &Metadata) -> bool {
true
}
#[cfg(target_os = "windows")]
#[cfg(windows)]
pub fn same_file(f1: &Metadata, f2: &Metadata) -> bool {
if f1.permissions() != f2.permissions() {
return false;