aboutsummaryrefslogtreecommitdiff
path: root/src/web/web_server.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-12-16 11:47:58 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-04 12:45:52 +0100
commit0bbb6673e7ce703e470a3c2aad620ee5f009bc84 (patch)
tree844e95b50e2bc129403b679a6c5d63ff82940ad6 /src/web/web_server.rs
parent53f71b3a57b3c1828292e26b7865d31e9bec44d6 (diff)
downloadgarage-0bbb6673e7ce703e470a3c2aad620ee5f009bc84.tar.gz
garage-0bbb6673e7ce703e470a3c2aad620ee5f009bc84.zip
Model changes
Diffstat (limited to 'src/web/web_server.rs')
-rw-r--r--src/web/web_server.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/web/web_server.rs b/src/web/web_server.rs
index 5eb25e93..6152f282 100644
--- a/src/web/web_server.rs
+++ b/src/web/web_server.rs
@@ -10,9 +10,13 @@ use hyper::{
};
use crate::error::*;
+
use garage_api::helpers::{authority_to_host, host_to_bucket};
use garage_api::s3_get::{handle_get, handle_head};
+
+use garage_model::bucket_table::Bucket;
use garage_model::garage::Garage;
+
use garage_table::*;
use garage_util::error::Error as GarageError;
@@ -84,16 +88,20 @@ async fn serve_file(garage: Arc<Garage>, req: Request<Body>) -> Result<Response<
.await?
.map(|x| x.state.take().into_option())
.flatten()
- .filter(|param| param.website_access)
.map(|param| param.bucket_id)
.ok_or(Error::NotFound)?;
- // Sanity check: check bucket isn't deleted
- garage
+ // Check bucket isn't deleted and has website access enabled
+ let _: Bucket = garage
.bucket_table
.get(&bucket_id, &EmptyKey)
.await?
- .filter(|b| !b.is_deleted())
+ .filter(|b| {
+ b.state
+ .as_option()
+ .map(|x| *x.website_access.get())
+ .unwrap_or(false)
+ })
.ok_or(Error::NotFound)?;
// Get path