object lifecycles (fix #309) #620

Merged
lx merged 25 commits from bucket-lifecycle into next 2023-09-04 09:45:11 +00:00
2 changed files with 2 additions and 12 deletions
Showing only changes of commit d2e94e36d6 - Show all commits

View file

@ -21,8 +21,6 @@ pub async fn handle_get_lifecycle(bucket: &Bucket) -> Result<Response<Body>, Err
.params()
.ok_or_internal_error("Bucket should not be deleted at this point")?;
trace!("bucket: {:#?}", bucket);
if let Some(lifecycle) = param.lifecycle_config.get() {
let wc = LifecycleConfiguration::from_garage_lifecycle_config(lifecycle);
let xml = to_xml_with_header(&wc)?;
@ -76,20 +74,12 @@ pub async fn handle_put_lifecycle(
let param = bucket.params_mut().unwrap();
let conf: LifecycleConfiguration = from_reader(&body as &[u8])?;
let config = conf
.validate_into_garage_lifecycle_config()
.ok_or_bad_request("Invalid lifecycle configuration")?;
param.lifecycle_config.update(Some(config));
garage.bucket_table.insert(&bucket).await?;
trace!("new bucket: {:#?}", bucket);
let bucket = garage
.bucket_helper()
.get_existing_bucket(bucket_id)
.await?;
trace!("new bucket again: {:#?}", bucket);
Ok(Response::builder()
.status(StatusCode::OK)
@ -281,7 +271,6 @@ impl Expiration {
(None, None) => Err("<Expiration> must contain either <Days> or <Date>"),
(Some(days), None) => Ok(GarageLifecycleExpiration::AfterDays(days.0 as usize)),
(None, Some(date)) => {
trace!("date: {}", date.0);
parse_lifecycle_date(&date.0)?;
Ok(GarageLifecycleExpiration::AtDate(date.0))
}

View file

@ -151,6 +151,7 @@ impl Crdt for BucketParams {
self.website_config.merge(&o.website_config);
self.cors_config.merge(&o.cors_config);
self.lifecycle_config.merge(&o.lifecycle_config);
self.quotas.merge(&o.quotas);
}
}