Merge branch 'main' of github.com:rustfs/s3-rustfs

* 'main' of github.com:rustfs/s3-rustfs:
  add Cargo.lock
  fix filemeta/intofileversions

# Conflicts:
#	Cargo.lock
This commit is contained in:
houseme
2025-06-06 12:19:29 +08:00
3 changed files with 40 additions and 27 deletions
Generated
+2 -2
View File
@@ -1483,9 +1483,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.25" version = "1.2.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0fc897dc1e865cc67c0e05a836d9d3f1df3cbe442aa4a9473b18e12624a4951" checksum = "956a5e21988b87f372569b66183b78babf23ebc2e744b733e4350a752c4dafac"
dependencies = [ dependencies = [
"jobserver", "jobserver",
"libc", "libc",
+20
View File
@@ -606,6 +606,26 @@ impl FileMeta {
versions.push(fi); versions.push(fi);
} }
let mut prev_mod_time = None;
for (i, fi) in versions.iter_mut().enumerate() {
if i == 0 {
fi.is_latest = true;
} else {
fi.successor_mod_time = prev_mod_time;
}
prev_mod_time = fi.mod_time;
}
if versions.is_empty() {
versions.push(FileInfo {
name: path.to_string(),
volume: volume.to_string(),
deleted: true,
is_latest: true,
..Default::default()
});
}
Ok(FileInfoVersions { Ok(FileInfoVersions {
volume: volume.to_string(), volume: volume.to_string(),
name: path.to_string(), name: path.to_string(),
+18 -25
View File
@@ -28,10 +28,10 @@ use ecstore::bucket::policy_sys::PolicySys;
use ecstore::bucket::tagging::decode_tags; use ecstore::bucket::tagging::decode_tags;
use ecstore::bucket::tagging::encode_tags; use ecstore::bucket::tagging::encode_tags;
use ecstore::bucket::versioning_sys::BucketVersioningSys; use ecstore::bucket::versioning_sys::BucketVersioningSys;
use ecstore::io::READ_BUFFER_SIZE;
use ecstore::cmd::bucket_replication::get_must_replicate_options; use ecstore::cmd::bucket_replication::get_must_replicate_options;
use ecstore::cmd::bucket_replication::must_replicate; use ecstore::cmd::bucket_replication::must_replicate;
use ecstore::cmd::bucket_replication::schedule_replication; use ecstore::cmd::bucket_replication::schedule_replication;
use ecstore::io::READ_BUFFER_SIZE;
use ecstore::new_object_layer_fn; use ecstore::new_object_layer_fn;
use ecstore::store_api::BucketOptions; use ecstore::store_api::BucketOptions;
use ecstore::store_api::CompletePart; use ecstore::store_api::CompletePart;
@@ -53,7 +53,6 @@ use futures::pin_mut;
use futures::{Stream, StreamExt}; use futures::{Stream, StreamExt};
use http::HeaderMap; use http::HeaderMap;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use tracing::debug;
use policy::auth; use policy::auth;
use policy::policy::action::Action; use policy::policy::action::Action;
use policy::policy::action::S3Action; use policy::policy::action::S3Action;
@@ -81,6 +80,7 @@ use tokio_stream::wrappers::ReceiverStream;
use tokio_tar::Archive; use tokio_tar::Archive;
use tokio_util::io::ReaderStream; use tokio_util::io::ReaderStream;
use tokio_util::io::StreamReader; use tokio_util::io::StreamReader;
use tracing::debug;
use tracing::error; use tracing::error;
use tracing::info; use tracing::info;
use tracing::warn; use tracing::warn;
@@ -993,7 +993,8 @@ impl S3 for FS {
.await .await
.map_err(to_s3_error)?; .map_err(to_s3_error)?;
let repoptions = get_must_replicate_options(&mt2, "", ReplicationStatusType::Unknown, ReplicationType::ObjectReplicationType , &opts); let repoptions =
get_must_replicate_options(&mt2, "", ReplicationStatusType::Unknown, ReplicationType::ObjectReplicationType, &opts);
let dsc = must_replicate(&bucket, &key, &repoptions).await; let dsc = must_replicate(&bucket, &key, &repoptions).await;
warn!("dsc {}", &dsc.replicate_any().clone()); warn!("dsc {}", &dsc.replicate_any().clone());
@@ -1001,14 +1002,11 @@ impl S3 for FS {
let k = format!("{}{}", RESERVED_METADATA_PREFIX_LOWER, "replication-timestamp"); let k = format!("{}{}", RESERVED_METADATA_PREFIX_LOWER, "replication-timestamp");
let now: DateTime<Utc> = Utc::now(); let now: DateTime<Utc> = Utc::now();
let formatted_time = now.to_rfc3339(); let formatted_time = now.to_rfc3339();
metadata.insert(k, formatted_time); metadata.insert(k, formatted_time);
let k = format!("{}{}", RESERVED_METADATA_PREFIX_LOWER, "replication-status"); let k = format!("{}{}", RESERVED_METADATA_PREFIX_LOWER, "replication-status");
metadata.insert(k, dsc.pending_status()); metadata.insert(k, dsc.pending_status());
} }
debug!("put_object opts {:?}", &opts); debug!("put_object opts {:?}", &opts);
let obj_info = store let obj_info = store
@@ -1018,8 +1016,8 @@ impl S3 for FS {
let e_tag = obj_info.etag.clone(); let e_tag = obj_info.etag.clone();
let repoptions =
let repoptions = get_must_replicate_options(&mt2, "", ReplicationStatusType::Unknown, ReplicationType::ObjectReplicationType , &opts); get_must_replicate_options(&mt2, "", ReplicationStatusType::Unknown, ReplicationType::ObjectReplicationType, &opts);
let dsc = must_replicate(&bucket, &key, &repoptions).await; let dsc = must_replicate(&bucket, &key, &repoptions).await;
@@ -1197,21 +1195,21 @@ impl S3 for FS {
let output = CompleteMultipartUploadOutput { let output = CompleteMultipartUploadOutput {
bucket: Some(bucket.clone()), bucket: Some(bucket.clone()),
key: Some(key.clone()), key: Some(key.clone()),
e_tag:obj_info.etag.clone(), e_tag: obj_info.etag.clone(),
location: Some("us-east-1".to_string()), location: Some("us-east-1".to_string()),
..Default::default() ..Default::default()
}; };
let mt2 = HashMap::new(); let mt2 = HashMap::new();
let repoptions = get_must_replicate_options(&mt2, "", ReplicationStatusType::Unknown, ReplicationType::ObjectReplicationType , &opts); let repoptions =
get_must_replicate_options(&mt2, "", ReplicationStatusType::Unknown, ReplicationType::ObjectReplicationType, opts);
let dsc = must_replicate(&bucket, &key, &repoptions).await; let dsc = must_replicate(&bucket, &key, &repoptions).await;
if dsc.replicate_any() { if dsc.replicate_any() {
warn!("need multipart replication"); warn!("need multipart replication");
let objectlayer = new_object_layer_fn(); let objectlayer = new_object_layer_fn();
schedule_replication(obj_info, objectlayer.unwrap(), dsc, 1).await; schedule_replication(obj_info, objectlayer.unwrap(), dsc, 1).await;
} }
Ok(S3Response::new(output)) Ok(S3Response::new(output))
} }
@@ -1783,32 +1781,27 @@ impl S3 for FS {
} }
}; };
if let None = rcfg { if rcfg.is_none() {
return Err(S3Error::with_message(S3ErrorCode::NoSuchBucket, "replication not found".to_string())); return Err(S3Error::with_message(S3ErrorCode::NoSuchBucket, "replication not found".to_string()));
} }
// Ok(S3Response::new(GetBucketReplicationOutput { // Ok(S3Response::new(GetBucketReplicationOutput {
// replication_configuration: rcfg, // replication_configuration: rcfg,
// })) // }))
if rcfg.is_some() { if rcfg.is_some() {
Ok(S3Response::new(GetBucketReplicationOutput { Ok(S3Response::new(GetBucketReplicationOutput {
replication_configuration: rcfg, replication_configuration: rcfg,
})) }))
} else { } else {
let rep = ReplicationConfiguration{ let rep = ReplicationConfiguration {
role: "".to_string(), role: "".to_string(),
rules: vec![], rules: vec![],
}; };
Ok(S3Response::new(GetBucketReplicationOutput { Ok(S3Response::new(GetBucketReplicationOutput {
replication_configuration: Some(rep), replication_configuration: Some(rep),
})) }))
} }
} }
async fn put_bucket_replication( async fn put_bucket_replication(