diff options
Diffstat (limited to 'src/garage')
-rw-r--r-- | src/garage/admin.rs | 16 | ||||
-rw-r--r-- | src/garage/cli/cmd.rs | 4 | ||||
-rw-r--r-- | src/garage/cli/util.rs | 4 |
3 files changed, 15 insertions, 9 deletions
diff --git a/src/garage/admin.rs b/src/garage/admin.rs index 0c1e58f8..bca1bc5a 100644 --- a/src/garage/admin.rs +++ b/src/garage/admin.rs @@ -140,7 +140,7 @@ impl AdminRpcHandler { } if let Some(alias) = self.garage.bucket_alias_table.get(&EmptyKey, name).await? { - if !alias.state.get().is_deleted() { + if alias.state.get().is_some() { return Err(Error::BadRequest(format!("Bucket {} already exists", name))); } } @@ -229,7 +229,7 @@ impl AdminRpcHandler { // 2. delete bucket alias if bucket_alias.is_some() { helper - .unset_global_bucket_alias(bucket_id, &query.name) + .purge_global_bucket_alias(bucket_id, &query.name) .await?; } @@ -281,7 +281,7 @@ impl AdminRpcHandler { .unwrap() .local_aliases .get(&query.name) - .map(|a| a.into_option()) + .cloned() .flatten() .ok_or_bad_request("Bucket not found")?; @@ -484,20 +484,26 @@ impl AdminRpcHandler { let state = key.state.as_option_mut().unwrap(); // --- done checking, now commit --- + // (the step at unset_local_bucket_alias will fail if a bucket + // does not have another alias, the deletion will be + // interrupted in the middle if that happens) + // 1. Delete local aliases for (alias, _, to) in state.local_aliases.items().iter() { - if let Deletable::Present(bucket_id) = to { + if let Some(bucket_id) = to { helper .unset_local_bucket_alias(*bucket_id, &key.key_id, alias) .await?; } } - // 2. Delete authorized buckets + + // 2. Remove permissions on all authorized buckets for (ab_id, _auth) in state.authorized_buckets.items().iter() { helper .set_bucket_key_permissions(*ab_id, &key.key_id, BucketKeyPerm::no_permissions()) .await?; } + // 3. Actually delete key key.state = Deletable::delete(); self.garage.key_table.insert(&key).await?; diff --git a/src/garage/cli/cmd.rs b/src/garage/cli/cmd.rs index cca7c401..515f2143 100644 --- a/src/garage/cli/cmd.rs +++ b/src/garage/cli/cmd.rs @@ -168,8 +168,8 @@ pub async fn cmd_admin( println!("List of buckets:"); let mut table = vec![]; for alias in bl { - if let Some(p) = alias.state.get().as_option() { - table.push(format!("\t{}\t{:?}", alias.name(), p.bucket_id)); + if let Some(alias_bucket) = alias.state.get() { + table.push(format!("\t{}\t{:?}", alias.name(), alias_bucket)); } } format_table(table); diff --git a/src/garage/cli/util.rs b/src/garage/cli/util.rs index b4ea14d1..8d31a4c5 100644 --- a/src/garage/cli/util.rs +++ b/src/garage/cli/util.rs @@ -34,7 +34,7 @@ pub fn print_key_info(key: &Key, relevant_buckets: &HashMap<Uuid, Bucket>) { println!("\nKey-specific bucket aliases:"); let mut table = vec![]; for (alias_name, _, alias) in p.local_aliases.items().iter() { - if let Some(bucket_id) = alias.as_option() { + if let Some(bucket_id) = alias { table.push(format!( "\t{}\t{}\t{}", alias_name, @@ -55,7 +55,7 @@ pub fn print_key_info(key: &Key, relevant_buckets: &HashMap<Uuid, Bucket>) { .local_aliases .items() .iter() - .filter(|(_, _, a)| a.as_option() == Some(bucket_id)) + .filter(|(_, _, a)| *a == Some(*bucket_id)) .map(|(a, _, _)| a.clone()) .collect::<Vec<_>>() .join(", "); |