diff options
author | Alex Auvolat <alex@adnab.me> | 2022-05-17 17:02:38 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-05-17 17:02:38 +0200 |
commit | e92c52eb6522a140cdced40bc047149dc638bfa4 (patch) | |
tree | e7789d71462f2d376613ef482962702839322efb /src | |
parent | 8b1338ef2fcd36214c3ad90f5d3585377f28ec86 (diff) | |
download | garage-e92c52eb6522a140cdced40bc047149dc638bfa4.tar.gz garage-e92c52eb6522a140cdced40bc047149dc638bfa4.zip |
refactor
Diffstat (limited to 'src')
-rw-r--r-- | src/api/admin/bucket.rs | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/src/api/admin/bucket.rs b/src/api/admin/bucket.rs index 2c21edee..2124f2c2 100644 --- a/src/api/admin/bucket.rs +++ b/src/api/admin/bucket.rs @@ -103,18 +103,18 @@ pub async fn handle_get_bucket_info( } }; - let bucket = garage - .bucket_helper() - .get_existing_bucket(bucket_id) - .await?; - - bucket_info_results(garage, bucket).await + bucket_info_results(garage, bucket_id).await } async fn bucket_info_results( garage: &Arc<Garage>, - bucket: Bucket, + bucket_id: Uuid, ) -> Result<Response<Body>, Error> { + let bucket = garage + .bucket_helper() + .get_existing_bucket(bucket_id) + .await?; + let mut relevant_keys = HashMap::new(); for (k, _) in bucket .state @@ -299,12 +299,7 @@ pub async fn handle_create_bucket( } } - let bucket = garage - .bucket_table - .get(&EmptyKey, &bucket.id) - .await? - .ok_or_internal_error("Bucket should now exist but doesn't")?; - bucket_info_results(garage, bucket).await + bucket_info_results(garage, bucket.id).await } #[derive(Deserialize)] @@ -425,12 +420,7 @@ pub async fn handle_bucket_change_key_perm( .set_bucket_key_permissions(bucket.id, &key.key_id, perm) .await?; - let bucket = garage - .bucket_table - .get(&EmptyKey, &bucket.id) - .await? - .ok_or_internal_error("Bucket should now exist but doesn't")?; - bucket_info_results(garage, bucket).await + bucket_info_results(garage, bucket.id).await } #[derive(Deserialize)] |