aboutsummaryrefslogtreecommitdiff
path: root/src/model/bucket_helper.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-12-17 11:53:13 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-04 12:46:41 +0100
commitb1cfd16913e6957739958ef729b87c1bf3674a5d (patch)
tree781245de967e0c7a14cbdc0f2a610787f3b852d4 /src/model/bucket_helper.rs
parent5db600e2316b80102e3fd4df9e8974c9586aec9c (diff)
downloadgarage-b1cfd16913e6957739958ef729b87c1bf3674a5d.tar.gz
garage-b1cfd16913e6957739958ef729b87c1bf3674a5d.zip
New buckets for 0.6.0: small fixes, including:
- ensure bucket names are correct aws s3 names - when making aliases, ensure timestamps of links in both ways are the same - fix small remarks by trinity - don't have a separate website_access field
Diffstat (limited to 'src/model/bucket_helper.rs')
-rw-r--r--src/model/bucket_helper.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/model/bucket_helper.rs b/src/model/bucket_helper.rs
index c1280afa..b55ebc4b 100644
--- a/src/model/bucket_helper.rs
+++ b/src/model/bucket_helper.rs
@@ -8,12 +8,21 @@ use crate::garage::Garage;
pub struct BucketHelper<'a>(pub(crate) &'a Garage);
-#[allow(clippy::ptr_arg)]
impl<'a> BucketHelper<'a> {
+ #[allow(clippy::ptr_arg)]
pub async fn resolve_global_bucket_name(
&self,
bucket_name: &String,
) -> Result<Option<Uuid>, Error> {
+ // Bucket names in Garage are aliases, true bucket identifiers
+ // are 32-byte UUIDs. This function resolves bucket names into
+ // their full identifier by looking up in the bucket_alias_table.
+ // This function also allows buckets to be identified by their
+ // full UUID (hex-encoded). Here, if the name to be resolved is a
+ // hex string of the correct length, it is directly parsed as a bucket
+ // identifier which is returned. There is no risk of this conflicting
+ // with an actual bucket name: bucket names are max 63 chars long by
+ // the AWS spec, and hex-encoded UUIDs are 64 chars long.
let hexbucket = hex::decode(bucket_name.as_str())
.ok()
.map(|by| Uuid::try_from(&by))
@@ -37,7 +46,6 @@ impl<'a> BucketHelper<'a> {
}
}
- #[allow(clippy::ptr_arg)]
pub async fn get_existing_bucket(&self, bucket_id: Uuid) -> Result<Bucket, Error> {
self.0
.bucket_table