mirror of
https://github.com/rustfs/rustfs.git
synced 2026-01-17 01:30:33 +00:00
fix
This commit is contained in:
@@ -161,7 +161,7 @@ pub trait Lifecycle {
|
||||
async fn has_transition(&self) -> bool;
|
||||
fn has_expiry(&self) -> bool;
|
||||
async fn has_active_rules(&self, prefix: &str) -> bool;
|
||||
async fn validate(&self, lr: &ObjectLockConfiguration) -> Result<(), std::io::Error>;
|
||||
async fn validate(&self, lr_retention: bool) -> Result<(), std::io::Error>;
|
||||
async fn filter_rules(&self, obj: &ObjectOpts) -> Option<Vec<LifecycleRule>>;
|
||||
async fn eval(&self, obj: &ObjectOpts) -> Event;
|
||||
async fn eval_inner(&self, obj: &ObjectOpts, now: OffsetDateTime) -> Event;
|
||||
@@ -242,7 +242,7 @@ impl Lifecycle for BucketLifecycleConfiguration {
|
||||
false
|
||||
}
|
||||
|
||||
async fn validate(&self, lr: &ObjectLockConfiguration) -> Result<(), std::io::Error> {
|
||||
async fn validate(&self, lr_retention: bool) -> Result<(), std::io::Error> {
|
||||
if self.rules.len() > 1000 {
|
||||
return Err(std::io::Error::other(ERR_LIFECYCLE_TOO_MANY_RULES));
|
||||
}
|
||||
@@ -252,17 +252,11 @@ impl Lifecycle for BucketLifecycleConfiguration {
|
||||
|
||||
for r in &self.rules {
|
||||
r.validate()?;
|
||||
if let Some(object_lock_enabled) = lr.object_lock_enabled.as_ref() {
|
||||
if let Some(expiration) = r.expiration.as_ref() {
|
||||
if let Some(expired_object_delete_marker) = expiration.expired_object_delete_marker {
|
||||
if object_lock_enabled.as_str() == ObjectLockEnabled::ENABLED && (!expired_object_delete_marker) {
|
||||
return Err(std::io::Error::other(ERR_LIFECYCLE_BUCKET_LOCKED));
|
||||
}
|
||||
} /*else {
|
||||
if object_lock_enabled.as_str() == ObjectLockEnabled::ENABLED {
|
||||
return Err(Error::msg(ERR_LIFECYCLE_BUCKET_LOCKED));
|
||||
if let Some(expiration) = r.expiration.as_ref() {
|
||||
if let Some(expired_object_delete_marker) = expiration.expired_object_delete_marker {
|
||||
if lr_retention && (!expired_object_delete_marker) {
|
||||
return Err(std::io::Error::other(ERR_LIFECYCLE_BUCKET_LOCKED));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1715,20 +1715,25 @@ impl S3 for FS {
|
||||
..
|
||||
} = req.input;
|
||||
|
||||
let mut lr_retention = false;
|
||||
let rcfg = metadata_sys::get_object_lock_config(&bucket).await;
|
||||
if rcfg.is_err() {
|
||||
return Err(S3Error::with_message(
|
||||
S3ErrorCode::Custom("BucketLockIsNotExist".into()),
|
||||
"bucket lock is not exist.",
|
||||
));
|
||||
if let Ok(rcfg) = rcfg {
|
||||
if let Some(rule) = rcfg.0.rule {
|
||||
if let Some(retention) = rule.default_retention {
|
||||
if let Some(mode) = retention.mode {
|
||||
if mode == ObjectLockRetentionMode::from_static(ObjectLockRetentionMode::GOVERNANCE) {
|
||||
lr_retention = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let rcfg = rcfg.expect("get_lifecycle_config err!").0;
|
||||
|
||||
//info!("lifecycle_configuration: {:?}", &lifecycle_configuration);
|
||||
|
||||
let Some(input_cfg) = lifecycle_configuration else { return Err(s3_error!(InvalidArgument)) };
|
||||
|
||||
if let Err(err) = input_cfg.validate(&rcfg).await {
|
||||
if let Err(err) = input_cfg.validate(lr_retention).await {
|
||||
//return Err(S3Error::with_message(S3ErrorCode::Custom("BucketLockValidateFailed".into()), "bucket lock validate failed."));
|
||||
return Err(S3Error::with_message(S3ErrorCode::Custom("ValidateFailed".into()), err.to_string()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user