More error refactoring

This commit is contained in:
Alex Auvolat
2022-05-13 15:21:32 +02:00
parent f82b938033
commit 7a5d329e49
12 changed files with 37 additions and 54 deletions
+1 -1
View File
@@ -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)
+2 -2
View File
@@ -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!(
+1 -2
View File
@@ -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(