s3 bucket apis: remove redundant call
This commit is contained in:
parent
d94f1c9178
commit
f0a395e2e5
4 changed files with 32 additions and 48 deletions
|
@ -355,19 +355,21 @@ impl ApiHandler for S3ApiServer {
|
||||||
}
|
}
|
||||||
Endpoint::GetBucketWebsite {} => handle_get_website(&bucket).await,
|
Endpoint::GetBucketWebsite {} => handle_get_website(&bucket).await,
|
||||||
Endpoint::PutBucketWebsite {} => {
|
Endpoint::PutBucketWebsite {} => {
|
||||||
handle_put_website(garage, bucket_id, req, content_sha256).await
|
handle_put_website(garage, bucket.clone(), req, content_sha256).await
|
||||||
}
|
}
|
||||||
Endpoint::DeleteBucketWebsite {} => handle_delete_website(garage, bucket_id).await,
|
Endpoint::DeleteBucketWebsite {} => handle_delete_website(garage, bucket.clone()).await,
|
||||||
Endpoint::GetBucketCors {} => handle_get_cors(&bucket).await,
|
Endpoint::GetBucketCors {} => handle_get_cors(&bucket).await,
|
||||||
Endpoint::PutBucketCors {} => {
|
Endpoint::PutBucketCors {} => {
|
||||||
handle_put_cors(garage, bucket_id, req, content_sha256).await
|
handle_put_cors(garage, bucket.clone(), req, content_sha256).await
|
||||||
}
|
}
|
||||||
Endpoint::DeleteBucketCors {} => handle_delete_cors(garage, bucket_id).await,
|
Endpoint::DeleteBucketCors {} => handle_delete_cors(garage, bucket.clone()).await,
|
||||||
Endpoint::GetBucketLifecycleConfiguration {} => handle_get_lifecycle(&bucket).await,
|
Endpoint::GetBucketLifecycleConfiguration {} => handle_get_lifecycle(&bucket).await,
|
||||||
Endpoint::PutBucketLifecycleConfiguration {} => {
|
Endpoint::PutBucketLifecycleConfiguration {} => {
|
||||||
handle_put_lifecycle(garage, bucket_id, req, content_sha256).await
|
handle_put_lifecycle(garage, bucket.clone(), req, content_sha256).await
|
||||||
|
}
|
||||||
|
Endpoint::DeleteBucketLifecycle {} => {
|
||||||
|
handle_delete_lifecycle(garage, bucket.clone()).await
|
||||||
}
|
}
|
||||||
Endpoint::DeleteBucketLifecycle {} => handle_delete_lifecycle(garage, bucket_id).await,
|
|
||||||
endpoint => Err(Error::NotImplemented(endpoint.name().to_owned())),
|
endpoint => Err(Error::NotImplemented(endpoint.name().to_owned())),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -44,14 +44,11 @@ pub async fn handle_get_cors(bucket: &Bucket) -> Result<Response<Body>, Error> {
|
||||||
|
|
||||||
pub async fn handle_delete_cors(
|
pub async fn handle_delete_cors(
|
||||||
garage: Arc<Garage>,
|
garage: Arc<Garage>,
|
||||||
bucket_id: Uuid,
|
mut bucket: Bucket,
|
||||||
) -> Result<Response<Body>, Error> {
|
) -> Result<Response<Body>, Error> {
|
||||||
let mut bucket = garage
|
let param = bucket
|
||||||
.bucket_helper()
|
.params_mut()
|
||||||
.get_existing_bucket(bucket_id)
|
.ok_or_internal_error("Bucket should not be deleted at this point")?;
|
||||||
.await?;
|
|
||||||
|
|
||||||
let param = bucket.params_mut().unwrap();
|
|
||||||
|
|
||||||
param.cors_config.update(None);
|
param.cors_config.update(None);
|
||||||
garage.bucket_table.insert(&bucket).await?;
|
garage.bucket_table.insert(&bucket).await?;
|
||||||
|
@ -63,7 +60,7 @@ pub async fn handle_delete_cors(
|
||||||
|
|
||||||
pub async fn handle_put_cors(
|
pub async fn handle_put_cors(
|
||||||
garage: Arc<Garage>,
|
garage: Arc<Garage>,
|
||||||
bucket_id: Uuid,
|
mut bucket: Bucket,
|
||||||
req: Request<Body>,
|
req: Request<Body>,
|
||||||
content_sha256: Option<Hash>,
|
content_sha256: Option<Hash>,
|
||||||
) -> Result<Response<Body>, Error> {
|
) -> Result<Response<Body>, Error> {
|
||||||
|
@ -73,12 +70,9 @@ pub async fn handle_put_cors(
|
||||||
verify_signed_content(content_sha256, &body[..])?;
|
verify_signed_content(content_sha256, &body[..])?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut bucket = garage
|
let param = bucket
|
||||||
.bucket_helper()
|
.params_mut()
|
||||||
.get_existing_bucket(bucket_id)
|
.ok_or_internal_error("Bucket should not be deleted at this point")?;
|
||||||
.await?;
|
|
||||||
|
|
||||||
let param = bucket.params_mut().unwrap();
|
|
||||||
|
|
||||||
let conf: CorsConfiguration = from_reader(&body as &[u8])?;
|
let conf: CorsConfiguration = from_reader(&body as &[u8])?;
|
||||||
conf.validate()?;
|
conf.validate()?;
|
||||||
|
|
|
@ -37,14 +37,11 @@ pub async fn handle_get_lifecycle(bucket: &Bucket) -> Result<Response<Body>, Err
|
||||||
|
|
||||||
pub async fn handle_delete_lifecycle(
|
pub async fn handle_delete_lifecycle(
|
||||||
garage: Arc<Garage>,
|
garage: Arc<Garage>,
|
||||||
bucket_id: Uuid,
|
mut bucket: Bucket,
|
||||||
) -> Result<Response<Body>, Error> {
|
) -> Result<Response<Body>, Error> {
|
||||||
let mut bucket = garage
|
let param = bucket
|
||||||
.bucket_helper()
|
.params_mut()
|
||||||
.get_existing_bucket(bucket_id)
|
.ok_or_internal_error("Bucket should not be deleted at this point")?;
|
||||||
.await?;
|
|
||||||
|
|
||||||
let param = bucket.params_mut().unwrap();
|
|
||||||
|
|
||||||
param.lifecycle_config.update(None);
|
param.lifecycle_config.update(None);
|
||||||
garage.bucket_table.insert(&bucket).await?;
|
garage.bucket_table.insert(&bucket).await?;
|
||||||
|
@ -56,7 +53,7 @@ pub async fn handle_delete_lifecycle(
|
||||||
|
|
||||||
pub async fn handle_put_lifecycle(
|
pub async fn handle_put_lifecycle(
|
||||||
garage: Arc<Garage>,
|
garage: Arc<Garage>,
|
||||||
bucket_id: Uuid,
|
mut bucket: Bucket,
|
||||||
req: Request<Body>,
|
req: Request<Body>,
|
||||||
content_sha256: Option<Hash>,
|
content_sha256: Option<Hash>,
|
||||||
) -> Result<Response<Body>, Error> {
|
) -> Result<Response<Body>, Error> {
|
||||||
|
@ -66,12 +63,9 @@ pub async fn handle_put_lifecycle(
|
||||||
verify_signed_content(content_sha256, &body[..])?;
|
verify_signed_content(content_sha256, &body[..])?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut bucket = garage
|
let param = bucket
|
||||||
.bucket_helper()
|
.params_mut()
|
||||||
.get_existing_bucket(bucket_id)
|
.ok_or_internal_error("Bucket should not be deleted at this point")?;
|
||||||
.await?;
|
|
||||||
|
|
||||||
let param = bucket.params_mut().unwrap();
|
|
||||||
|
|
||||||
let conf: LifecycleConfiguration = from_reader(&body as &[u8])?;
|
let conf: LifecycleConfiguration = from_reader(&body as &[u8])?;
|
||||||
let config = conf
|
let config = conf
|
||||||
|
|
|
@ -43,14 +43,11 @@ pub async fn handle_get_website(bucket: &Bucket) -> Result<Response<Body>, Error
|
||||||
|
|
||||||
pub async fn handle_delete_website(
|
pub async fn handle_delete_website(
|
||||||
garage: Arc<Garage>,
|
garage: Arc<Garage>,
|
||||||
bucket_id: Uuid,
|
mut bucket: Bucket,
|
||||||
) -> Result<Response<Body>, Error> {
|
) -> Result<Response<Body>, Error> {
|
||||||
let mut bucket = garage
|
let param = bucket
|
||||||
.bucket_helper()
|
.params_mut()
|
||||||
.get_existing_bucket(bucket_id)
|
.ok_or_internal_error("Bucket should not be deleted at this point")?;
|
||||||
.await?;
|
|
||||||
|
|
||||||
let param = bucket.params_mut().unwrap();
|
|
||||||
|
|
||||||
param.website_config.update(None);
|
param.website_config.update(None);
|
||||||
garage.bucket_table.insert(&bucket).await?;
|
garage.bucket_table.insert(&bucket).await?;
|
||||||
|
@ -62,7 +59,7 @@ pub async fn handle_delete_website(
|
||||||
|
|
||||||
pub async fn handle_put_website(
|
pub async fn handle_put_website(
|
||||||
garage: Arc<Garage>,
|
garage: Arc<Garage>,
|
||||||
bucket_id: Uuid,
|
mut bucket: Bucket,
|
||||||
req: Request<Body>,
|
req: Request<Body>,
|
||||||
content_sha256: Option<Hash>,
|
content_sha256: Option<Hash>,
|
||||||
) -> Result<Response<Body>, Error> {
|
) -> Result<Response<Body>, Error> {
|
||||||
|
@ -72,12 +69,9 @@ pub async fn handle_put_website(
|
||||||
verify_signed_content(content_sha256, &body[..])?;
|
verify_signed_content(content_sha256, &body[..])?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut bucket = garage
|
let param = bucket
|
||||||
.bucket_helper()
|
.params_mut()
|
||||||
.get_existing_bucket(bucket_id)
|
.ok_or_internal_error("Bucket should not be deleted at this point")?;
|
||||||
.await?;
|
|
||||||
|
|
||||||
let param = bucket.params_mut().unwrap();
|
|
||||||
|
|
||||||
let conf: WebsiteConfiguration = from_reader(&body as &[u8])?;
|
let conf: WebsiteConfiguration = from_reader(&body as &[u8])?;
|
||||||
conf.validate()?;
|
conf.validate()?;
|
||||||
|
|
Loading…
Reference in a new issue