mirror of
https://github.com/rustfs/rustfs.git
synced 2026-01-17 01:30:33 +00:00
fix:上传同名文件时删除旧版本
This commit is contained in:
@@ -36,9 +36,9 @@ impl Erasure {
|
||||
|
||||
Erasure {
|
||||
data_shards,
|
||||
parity_shards: parity_shards,
|
||||
parity_shards,
|
||||
block_size,
|
||||
encoder: encoder,
|
||||
encoder,
|
||||
_id: Uuid::new_v4(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,12 +454,12 @@ fn is_reserved_bucket(bucket_name: &str) -> bool {
|
||||
|
||||
// 检查桶名是否为保留名或无效名
|
||||
fn is_reserved_or_invalid_bucket(bucket_entry: &str, strict: bool) -> bool {
|
||||
if bucket_entry == "" {
|
||||
if bucket_entry.is_empty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
let bucket_entry = bucket_entry.trim_end_matches('/');
|
||||
let result = check_bucket_name(&bucket_entry, strict).is_err();
|
||||
let result = check_bucket_name(bucket_entry, strict).is_err();
|
||||
|
||||
result || is_meta_bucket(&bucket_entry) || is_reserved_bucket(&bucket_entry)
|
||||
result || is_meta_bucket(bucket_entry) || is_reserved_bucket(bucket_entry)
|
||||
}
|
||||
|
||||
@@ -3,4 +3,3 @@ pub mod ellipses;
|
||||
pub mod hash;
|
||||
pub mod net;
|
||||
pub mod path;
|
||||
pub mod string;
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
// use std::collections::HashMap;
|
||||
// use std::fmt;
|
||||
|
||||
// #[derive(Debug, Clone)]
|
||||
// pub struct StringSet(HashMap<String, ()>);
|
||||
|
||||
// impl StringSet {
|
||||
// // ToSlice - returns StringSet as a vector of strings.
|
||||
// pub fn to_slice(&self) -> Vec<String> {
|
||||
// let mut keys = self.0.keys().cloned().collect::<Vec<String>>();
|
||||
// keys.sort();
|
||||
// keys
|
||||
// }
|
||||
|
||||
// // IsEmpty - returns whether the set is empty or not.
|
||||
// pub fn is_empty(&self) -> bool {
|
||||
// self.0.len() == 0
|
||||
// }
|
||||
|
||||
// // Add - adds a string to the set.
|
||||
// pub fn add(&mut self, s: String) {
|
||||
// self.0.insert(s, ());
|
||||
// }
|
||||
|
||||
// // Remove - removes a string from the set. It does nothing if the string does not exist in the set.
|
||||
// pub fn remove(&mut self, s: &str) {
|
||||
// self.0.remove(s);
|
||||
// }
|
||||
|
||||
// // Contains - checks if a string is in the set.
|
||||
// pub fn contains(&self, s: &str) -> bool {
|
||||
// self.0.contains_key(s)
|
||||
// }
|
||||
|
||||
// // FuncMatch - returns a new set containing each value that passes the match function.
|
||||
// pub fn func_match<F>(&self, match_fn: F, match_string: &str) -> StringSet
|
||||
// where
|
||||
// F: Fn(&str, &str) -> bool,
|
||||
// {
|
||||
// StringSet(
|
||||
// self.0
|
||||
// .iter()
|
||||
// .filter(|(k, _)| match_fn(k, match_string))
|
||||
// .map(|(k, _)| (k.clone(), ()))
|
||||
// .collect::<HashMap<String, ()>>(),
|
||||
// )
|
||||
// }
|
||||
|
||||
// // ApplyFunc - returns a new set containing each value processed by 'apply_fn'.
|
||||
// pub fn apply_func<F>(&self, apply_fn: F) -> StringSet
|
||||
// where
|
||||
// F: Fn(&str) -> String,
|
||||
// {
|
||||
// StringSet(
|
||||
// self.0
|
||||
// .iter()
|
||||
// .map(|(k, _)| (apply_fn(k), ()))
|
||||
// .collect::<HashMap<String, ()>>(),
|
||||
// )
|
||||
// }
|
||||
|
||||
// // Equals - checks whether the given set is equal to the current set or not.
|
||||
// pub fn equals(&self, other: &StringSet) -> bool {
|
||||
// if self.0.len() != other.0.len() {
|
||||
// return false;
|
||||
// }
|
||||
// self.0.iter().all(|(k, _)| other.0.contains_key(k))
|
||||
// }
|
||||
|
||||
// // Intersection - returns the intersection with the given set as a new set.
|
||||
// pub fn intersection(&self, other: &StringSet) -> StringSet {
|
||||
// StringSet(
|
||||
// self.0
|
||||
// .iter()
|
||||
// .filter(|(k, _)| other.0.contains_key::<String>(k))
|
||||
// .map(|(k, _)| (k.clone(), ()))
|
||||
// .collect::<HashMap<String, ()>>(),
|
||||
// )
|
||||
// }
|
||||
|
||||
// // Difference - returns the difference with the given set as a new set.
|
||||
// pub fn difference(&self, other: &StringSet) -> StringSet {
|
||||
// StringSet(
|
||||
// self.0
|
||||
// .iter()
|
||||
// .filter(|(k, _)| !other.0.contains_key::<String>(k))
|
||||
// .map(|(k, _)| (k.clone(), ()))
|
||||
// .collect::<HashMap<String, ()>>(),
|
||||
// )
|
||||
// }
|
||||
|
||||
// // Union - returns the union with the given set as a new set.
|
||||
// pub fn union(&self, other: &StringSet) -> StringSet {
|
||||
// let mut new_set = self.clone();
|
||||
// for (k, _) in other.0.iter() {
|
||||
// new_set.0.insert(k.clone(), ());
|
||||
// }
|
||||
// new_set
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Implementing JSON serialization and deserialization would require the serde crate.
|
||||
// // You would also need to implement Display and PartialEq traits for more idiomatic Rust.
|
||||
|
||||
// // Implementing Display trait to provide a string representation of the set.
|
||||
// impl fmt::Display for StringSet {
|
||||
// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
// write!(f, "{}", self.to_slice().join(", "))
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Implementing PartialEq and Eq traits to allow comparison of StringSet instances.
|
||||
// impl PartialEq for StringSet {
|
||||
// fn eq(&self, other: &StringSet) -> bool {
|
||||
// self.equals(other)
|
||||
// }
|
||||
// }
|
||||
|
||||
// impl Eq for StringSet {}
|
||||
|
||||
// // NewStringSet - creates a new string set.
|
||||
// pub fn new_string_set() -> StringSet {
|
||||
// StringSet(HashMap::new())
|
||||
// }
|
||||
|
||||
// // CreateStringSet - creates a new string set with given string values.
|
||||
// pub fn create_string_set(sl: Vec<String>) -> StringSet {
|
||||
// let mut set = new_string_set();
|
||||
// for k in sl {
|
||||
// set.add(k);
|
||||
// }
|
||||
// set
|
||||
// }
|
||||
@@ -155,12 +155,12 @@ impl S3 for FS {
|
||||
let info = reader.object_info;
|
||||
|
||||
let content_type = try_!(ContentType::from_str("application/x-msdownload"));
|
||||
let last_modified = info.mod_time.map(|v| Timestamp::from(v));
|
||||
let last_modified = info.mod_time.map(Timestamp::from);
|
||||
|
||||
let output = GetObjectOutput {
|
||||
body: Some(reader.stream),
|
||||
content_length: Some(info.size as i64),
|
||||
last_modified: last_modified,
|
||||
last_modified,
|
||||
content_type: Some(content_type),
|
||||
..Default::default()
|
||||
};
|
||||
@@ -194,12 +194,12 @@ impl S3 for FS {
|
||||
debug!("info {:?}", info);
|
||||
|
||||
let content_type = try_!(ContentType::from_str("application/x-msdownload"));
|
||||
let last_modified = info.mod_time.map(|v| Timestamp::from(v));
|
||||
let last_modified = info.mod_time.map(Timestamp::from);
|
||||
|
||||
let output = HeadObjectOutput {
|
||||
content_length: Some(try_!(i64::try_from(info.size))),
|
||||
content_type: Some(content_type),
|
||||
last_modified: last_modified,
|
||||
last_modified,
|
||||
// metadata: object_metadata,
|
||||
..Default::default()
|
||||
};
|
||||
@@ -215,7 +215,7 @@ impl S3 for FS {
|
||||
let buckets: Vec<Bucket> = bucket_infos
|
||||
.iter()
|
||||
.map(|v| Bucket {
|
||||
creation_date: v.created.map(|v| Timestamp::from(v)),
|
||||
creation_date: v.created.map(Timestamp::from),
|
||||
name: Some(v.name.clone()),
|
||||
})
|
||||
.collect();
|
||||
|
||||
Reference in New Issue
Block a user