aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-01-03 18:32:15 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-04 12:52:47 +0100
commit1bcd6fabbdc0cd9dee88ba28daecb5339f2c13ec (patch)
tree6a812200ac8e049c21702ae1623a516d6e274f28 /src/api
parentba7f268b990cd17c5d20bf9e0eb6ff77d30fe845 (diff)
downloadgarage-1bcd6fabbdc0cd9dee88ba28daecb5339f2c13ec.tar.gz
garage-1bcd6fabbdc0cd9dee88ba28daecb5339f2c13ec.zip
New buckets for 0.6.0: small changes
- Fix bucket delete - fix merge of bucket creation date - Replace deletable with option in aliases Rationale: if two aliases point to conflicting bucket, resolving by making an arbitrary choice risks making data accessible when it shouldn't be. We'd rather resolve to deleting the alias until someone puts it back.
Diffstat (limited to 'src/api')
-rw-r--r--src/api/api_server.rs4
-rw-r--r--src/api/s3_bucket.rs8
2 files changed, 5 insertions, 7 deletions
diff --git a/src/api/api_server.rs b/src/api/api_server.rs
index 42987e78..f5ebed37 100644
--- a/src/api/api_server.rs
+++ b/src/api/api_server.rs
@@ -7,7 +7,6 @@ use hyper::server::conn::AddrStream;
use hyper::service::{make_service_fn, service_fn};
use hyper::{Body, Request, Response, Server};
-use garage_util::crdt;
use garage_util::data::*;
use garage_util::error::Error as GarageError;
@@ -306,8 +305,7 @@ async fn resolve_bucket(
.as_option()
.ok_or_else(|| Error::Forbidden("Operation is not allowed for this key.".to_string()))?;
- if let Some(crdt::Deletable::Present(bucket_id)) = api_key_params.local_aliases.get(bucket_name)
- {
+ if let Some(Some(bucket_id)) = api_key_params.local_aliases.get(bucket_name) {
Ok(*bucket_id)
} else {
Ok(garage
diff --git a/src/api/s3_bucket.rs b/src/api/s3_bucket.rs
index 785b89dd..24ec6b98 100644
--- a/src/api/s3_bucket.rs
+++ b/src/api/s3_bucket.rs
@@ -65,8 +65,8 @@ pub async fn handle_list_buckets(garage: &Garage, api_key: &Key) -> Result<Respo
if *active {
let alias_ent = garage.bucket_alias_table.get(&EmptyKey, alias).await?;
if let Some(alias_ent) = alias_ent {
- if let Some(alias_p) = alias_ent.state.get().as_option() {
- if alias_p.bucket_id == *bucket_id {
+ if let Some(alias_bucket) = alias_ent.state.get() {
+ if alias_bucket == bucket_id {
aliases.insert(alias_ent.name().to_string(), *bucket_id);
}
}
@@ -78,8 +78,8 @@ pub async fn handle_list_buckets(garage: &Garage, api_key: &Key) -> Result<Respo
}
}
- for (alias, _, id) in key_state.local_aliases.items() {
- if let Some(id) = id.as_option() {
+ for (alias, _, id_opt) in key_state.local_aliases.items() {
+ if let Some(id) = id_opt {
aliases.insert(alias.clone(), *id);
}
}