mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-09-04 19:25:42 +00:00
api: change ExpectedChecksums to not be a reference
This commit is contained in:
+6
-7
@@ -149,15 +149,14 @@ pub async fn handle_copy(
|
|||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
} else {
|
} else {
|
||||||
let expected_checksum = ExpectedChecksums {
|
|
||||||
md5: None,
|
|
||||||
sha256: None,
|
|
||||||
extra: source_checksum,
|
|
||||||
};
|
|
||||||
let checksum_mode = if was_multipart || source_checksum_algorithm != checksum_algorithm {
|
let checksum_mode = if was_multipart || source_checksum_algorithm != checksum_algorithm {
|
||||||
ChecksumMode::Calculate(checksum_algorithm)
|
ChecksumMode::Calculate(checksum_algorithm)
|
||||||
} else {
|
} else {
|
||||||
ChecksumMode::Verify(&expected_checksum)
|
ChecksumMode::Verify(ExpectedChecksums {
|
||||||
|
md5: None,
|
||||||
|
sha256: None,
|
||||||
|
extra: source_checksum,
|
||||||
|
})
|
||||||
};
|
};
|
||||||
// For multipart uploads that had a composite checksum, set checksum type
|
// For multipart uploads that had a composite checksum, set checksum type
|
||||||
// to full object as it will be recalculated.
|
// to full object as it will be recalculated.
|
||||||
@@ -345,7 +344,7 @@ async fn handle_copy_reencrypt(
|
|||||||
source_version: &ObjectVersion,
|
source_version: &ObjectVersion,
|
||||||
source_version_data: &ObjectVersionData,
|
source_version_data: &ObjectVersionData,
|
||||||
source_encryption: EncryptionParams,
|
source_encryption: EncryptionParams,
|
||||||
checksum_mode: ChecksumMode<'_>,
|
checksum_mode: ChecksumMode,
|
||||||
) -> Result<SaveStreamResult, Error> {
|
) -> Result<SaveStreamResult, Error> {
|
||||||
// basically we will read the source data (decrypt if necessary)
|
// basically we will read the source data (decrypt if necessary)
|
||||||
// and save that in a new object (encrypt if necessary),
|
// and save that in a new object (encrypt if necessary),
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ pub async fn handle_post_object(
|
|||||||
encryption,
|
encryption,
|
||||||
StreamLimiter::new(stream, conditions.content_length),
|
StreamLimiter::new(stream, conditions.content_length),
|
||||||
&key,
|
&key,
|
||||||
ChecksumMode::Verify(&expected_checksums),
|
ChecksumMode::Verify(expected_checksums),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -48,8 +48,8 @@ pub(crate) struct SaveStreamResult {
|
|||||||
pub(crate) etag: String,
|
pub(crate) etag: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) enum ChecksumMode<'a> {
|
pub(crate) enum ChecksumMode {
|
||||||
Verify(&'a ExpectedChecksums),
|
Verify(ExpectedChecksums),
|
||||||
VerifyFrom {
|
VerifyFrom {
|
||||||
checksummer: StreamingChecksumReceiver,
|
checksummer: StreamingChecksumReceiver,
|
||||||
trailer_algo: Option<ChecksumAlgorithm>,
|
trailer_algo: Option<ChecksumAlgorithm>,
|
||||||
@@ -140,7 +140,7 @@ pub(crate) async fn save_stream<S: Stream<Item = Result<Bytes, Error>> + Unpin>(
|
|||||||
encryption: EncryptionParams,
|
encryption: EncryptionParams,
|
||||||
body: S,
|
body: S,
|
||||||
key: &String,
|
key: &String,
|
||||||
checksum_mode: ChecksumMode<'_>,
|
checksum_mode: ChecksumMode,
|
||||||
) -> Result<SaveStreamResult, Error> {
|
) -> Result<SaveStreamResult, Error> {
|
||||||
let ReqCtx {
|
let ReqCtx {
|
||||||
garage, bucket_id, ..
|
garage, bucket_id, ..
|
||||||
|
|||||||
Reference in New Issue
Block a user