admin api: avoid overwriting redirect rules in UpdateBucket

This commit is contained in:
Alex Auvolat 2025-02-18 19:34:56 +01:00
parent 5645c82fb8
commit 01701acba1
2 changed files with 12 additions and 4 deletions

View file

@ -419,13 +419,17 @@ pub async fn handle_update_bucket(
if let Some(wa) = req.website_access {
if wa.enabled {
let (redirect_all, routing_rules) = match state.website_config.get() {
Some(wc) => (wc.redirect_all.clone(), wc.routing_rules.clone()),
None => (None, Vec::new()),
};
state.website_config.update(Some(WebsiteConfig {
index_document: wa.index_document.ok_or_bad_request(
"Please specify indexDocument when enabling website access.",
)?,
error_document: wa.error_document,
redirect_all: None,
routing_rules: Vec::new(),
redirect_all,
routing_rules,
}));
} else {
if wa.index_document.is_some() || wa.error_document.is_some() {

View file

@ -390,11 +390,15 @@ impl AdminRpcHandler {
}
let website = if query.allow {
let (redirect_all, routing_rules) = match bucket_state.website_config.get() {
Some(wc) => (wc.redirect_all.clone(), wc.routing_rules.clone()),
None => (None, Vec::new()),
};
Some(WebsiteConfig {
index_document: query.index_document.clone(),
error_document: query.error_document.clone(),
redirect_all: None,
routing_rules: Vec::new(),
redirect_all,
routing_rules,
})
} else {
None