diff --git a/Cargo.lock b/Cargo.lock index 8ab70944..590476e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1483,9 +1483,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.25" +version = "1.2.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0fc897dc1e865cc67c0e05a836d9d3f1df3cbe442aa4a9473b18e12624a4951" +checksum = "956a5e21988b87f372569b66183b78babf23ebc2e744b733e4350a752c4dafac" dependencies = [ "jobserver", "libc", diff --git a/ecstore/src/file_meta.rs b/ecstore/src/file_meta.rs index 182d998b..d71cf4c7 100644 --- a/ecstore/src/file_meta.rs +++ b/ecstore/src/file_meta.rs @@ -606,6 +606,26 @@ impl FileMeta { 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 { volume: volume.to_string(), name: path.to_string(), diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index 0b920e03..0d173a1e 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -28,10 +28,10 @@ use ecstore::bucket::policy_sys::PolicySys; use ecstore::bucket::tagging::decode_tags; use ecstore::bucket::tagging::encode_tags; 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::must_replicate; use ecstore::cmd::bucket_replication::schedule_replication; +use ecstore::io::READ_BUFFER_SIZE; use ecstore::new_object_layer_fn; use ecstore::store_api::BucketOptions; use ecstore::store_api::CompletePart; @@ -53,7 +53,6 @@ use futures::pin_mut; use futures::{Stream, StreamExt}; use http::HeaderMap; use lazy_static::lazy_static; -use tracing::debug; use policy::auth; use policy::policy::action::Action; use policy::policy::action::S3Action; @@ -81,6 +80,7 @@ use tokio_stream::wrappers::ReceiverStream; use tokio_tar::Archive; use tokio_util::io::ReaderStream; use tokio_util::io::StreamReader; +use tracing::debug; use tracing::error; use tracing::info; use tracing::warn; @@ -993,7 +993,8 @@ impl S3 for FS { .await .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; warn!("dsc {}", &dsc.replicate_any().clone()); @@ -1001,14 +1002,11 @@ impl S3 for FS { let k = format!("{}{}", RESERVED_METADATA_PREFIX_LOWER, "replication-timestamp"); let now: DateTime = Utc::now(); 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"); metadata.insert(k, dsc.pending_status()); } - - - debug!("put_object opts {:?}", &opts); let obj_info = store @@ -1018,8 +1016,8 @@ impl S3 for FS { let e_tag = obj_info.etag.clone(); - - 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; @@ -1197,21 +1195,21 @@ impl S3 for FS { let output = CompleteMultipartUploadOutput { bucket: Some(bucket.clone()), key: Some(key.clone()), - e_tag:obj_info.etag.clone(), + e_tag: obj_info.etag.clone(), location: Some("us-east-1".to_string()), ..Default::default() }; - 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; - + if dsc.replicate_any() { - warn!("need multipart replication"); - let objectlayer = new_object_layer_fn(); - schedule_replication(obj_info, objectlayer.unwrap(), dsc, 1).await; + warn!("need multipart replication"); + let objectlayer = new_object_layer_fn(); + schedule_replication(obj_info, objectlayer.unwrap(), dsc, 1).await; } Ok(S3Response::new(output)) } @@ -1783,32 +1781,27 @@ impl S3 for FS { } }; - if let None = rcfg { - return Err(S3Error::with_message(S3ErrorCode::NoSuchBucket, "replication not found".to_string())); + if rcfg.is_none() { + return Err(S3Error::with_message(S3ErrorCode::NoSuchBucket, "replication not found".to_string())); } - - // Ok(S3Response::new(GetBucketReplicationOutput { // replication_configuration: rcfg, // })) - if rcfg.is_some() { Ok(S3Response::new(GetBucketReplicationOutput { replication_configuration: rcfg, })) } else { - let rep = ReplicationConfiguration{ + let rep = ReplicationConfiguration { role: "".to_string(), rules: vec![], }; Ok(S3Response::new(GetBucketReplicationOutput { replication_configuration: Some(rep), - })) + })) } - - } async fn put_bucket_replication(