aboutsummaryrefslogtreecommitdiff
path: root/src/api/s3
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-05-13 15:21:32 +0200
committerAlex Auvolat <alex@adnab.me>2022-05-13 15:21:32 +0200
commit7a5d329e49cc7018cbfa14d37589f51860f66cf0 (patch)
tree50be9a5eea1b2415bb541aff0c8cb33c0f47b8e4 /src/api/s3
parentf82b938033f1a01a136315b5f37ecb89b78bca0c (diff)
downloadgarage-7a5d329e49cc7018cbfa14d37589f51860f66cf0.tar.gz
garage-7a5d329e49cc7018cbfa14d37589f51860f66cf0.zip
More error refactoring
Diffstat (limited to 'src/api/s3')
-rw-r--r--src/api/s3/api_server.rs2
-rw-r--r--src/api/s3/copy.rs4
-rw-r--r--src/api/s3/post_object.rs3
3 files changed, 4 insertions, 5 deletions
diff --git a/src/api/s3/api_server.rs b/src/api/s3/api_server.rs
index 77ac3879..6b565fd0 100644
--- a/src/api/s3/api_server.rs
+++ b/src/api/s3/api_server.rs
@@ -149,7 +149,7 @@ impl ApiHandler for S3ApiServer {
return handle_create_bucket(&garage, req, content_sha256, api_key, bucket_name).await;
}
- let bucket_id = resolve_bucket(&garage, &bucket_name, &api_key).await?;
+ let bucket_id = garage.bucket_helper().resolve_bucket(&bucket_name, &api_key).await?;
let bucket = garage
.bucket_table
.get(&EmptyKey, &bucket_id)
diff --git a/src/api/s3/copy.rs b/src/api/s3/copy.rs
index abd90f4a..2468678e 100644
--- a/src/api/s3/copy.rs
+++ b/src/api/s3/copy.rs
@@ -19,7 +19,7 @@ use garage_model::s3::object_table::*;
use garage_model::s3::version_table::*;
use crate::s3::error::*;
-use crate::helpers::{parse_bucket_key, resolve_bucket};
+use crate::helpers::{parse_bucket_key};
use crate::s3::put::{decode_upload_id, get_headers};
use crate::s3::xml::{self as s3_xml, xmlns_tag};
@@ -413,7 +413,7 @@ async fn get_copy_source(
let copy_source = percent_encoding::percent_decode_str(copy_source).decode_utf8()?;
let (source_bucket, source_key) = parse_bucket_key(&copy_source, None)?;
- let source_bucket_id = resolve_bucket(garage, &source_bucket.to_string(), api_key).await?;
+ let source_bucket_id = garage.bucket_helper().resolve_bucket(&source_bucket.to_string(), api_key).await?;
if !api_key.allow_read(&source_bucket_id) {
return Err(Error::Forbidden(format!(
diff --git a/src/api/s3/post_object.rs b/src/api/s3/post_object.rs
index 343aa366..c4b63452 100644
--- a/src/api/s3/post_object.rs
+++ b/src/api/s3/post_object.rs
@@ -15,7 +15,6 @@ use serde::Deserialize;
use garage_model::garage::Garage;
use crate::s3::error::*;
-use crate::helpers::resolve_bucket;
use crate::s3::put::{get_headers, save_stream};
use crate::s3::xml as s3_xml;
use crate::signature::payload::{parse_date, verify_v4};
@@ -129,7 +128,7 @@ pub async fn handle_post_object(
)
.await?;
- let bucket_id = resolve_bucket(&garage, &bucket, &api_key).await?;
+ let bucket_id = garage.bucket_helper().resolve_bucket(&bucket, &api_key).await?;
if !api_key.allow_write(&bucket_id) {
return Err(Error::Forbidden(