aboutsummaryrefslogtreecommitdiff
path: root/src/api/s3_website.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-12-14 13:55:11 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-04 12:45:46 +0100
commit5b1117e582db16cc5aa50840a685875cbd5501f4 (patch)
tree06fec47bf56cb08cb51334454dc15f98352c98f2 /src/api/s3_website.rs
parent8f6026de5ecd44cbe0fc0bcd47638a1ece860439 (diff)
downloadgarage-5b1117e582db16cc5aa50840a685875cbd5501f4.tar.gz
garage-5b1117e582db16cc5aa50840a685875cbd5501f4.zip
New model for buckets
Diffstat (limited to 'src/api/s3_website.rs')
-rw-r--r--src/api/s3_website.rs27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/api/s3_website.rs b/src/api/s3_website.rs
index 37c8b86c..da67c4cd 100644
--- a/src/api/s3_website.rs
+++ b/src/api/s3_website.rs
@@ -7,9 +7,10 @@ use serde::{Deserialize, Serialize};
use crate::error::*;
use crate::s3_xml::{xmlns_tag, IntValue, Value};
use crate::signature::verify_signed_content;
-use garage_model::bucket_table::BucketState;
+
use garage_model::garage::Garage;
use garage_table::*;
+use garage_util::crdt;
use garage_util::data::Hash;
pub async fn handle_delete_website(
@@ -17,14 +18,18 @@ pub async fn handle_delete_website(
bucket: String,
) -> Result<Response<Body>, Error> {
let mut bucket = garage
- .bucket_table
+ .bucket_alias_table
.get(&EmptyKey, &bucket)
.await?
.ok_or(Error::NotFound)?;
- if let BucketState::Present(state) = bucket.state.get_mut() {
- state.website.update(false);
- garage.bucket_table.insert(&bucket).await?;
+ if let crdt::Deletable::Present(state) = bucket.state.get_mut() {
+ let mut new_param = state.clone();
+ new_param.website_access = false;
+ bucket.state.update(crdt::Deletable::present(new_param));
+ garage.bucket_alias_table.insert(&bucket).await?;
+ } else {
+ unreachable!();
}
Ok(Response::builder()
@@ -43,7 +48,7 @@ pub async fn handle_put_website(
verify_signed_content(content_sha256, &body[..])?;
let mut bucket = garage
- .bucket_table
+ .bucket_alias_table
.get(&EmptyKey, &bucket)
.await?
.ok_or(Error::NotFound)?;
@@ -51,9 +56,13 @@ pub async fn handle_put_website(
let conf: WebsiteConfiguration = from_reader(&body as &[u8])?;
conf.validate()?;
- if let BucketState::Present(state) = bucket.state.get_mut() {
- state.website.update(true);
- garage.bucket_table.insert(&bucket).await?;
+ if let crdt::Deletable::Present(state) = bucket.state.get() {
+ let mut new_param = state.clone();
+ new_param.website_access = true;
+ bucket.state.update(crdt::Deletable::present(new_param));
+ garage.bucket_alias_table.insert(&bucket).await?;
+ } else {
+ unreachable!();
}
Ok(Response::builder()