Skip to content

Commit 197542b

Browse files
committed
WIP
1 parent 1f4a59b commit 197542b

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

include/aws/s3/private/s3_checksum_context.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,20 @@ struct aws_s3_upload_request_checksum_context *aws_s3_upload_request_checksum_co
5151
const struct aws_s3_meta_request_checksum_config_storage *checksum_config);
5252

5353
/**
54-
* Create a new upload request checksum context with an existing checksum value.
54+
* Create a new upload request checksum context with an existing base64 encoded checksum value.
5555
* This is useful when resuming uploads or when the checksum is pre-calculated.
5656
* Returns with reference count of 1.
5757
*
5858
* @param allocator Memory allocator
5959
* @param checksum_config Meta request level checksum configuration (can be NULL)
60-
* @param existing_checksum Pre-calculated checksum value as a byte cursor
60+
* @param existing_base64_checksum Pre-calculated checksum value as a byte cursor
6161
* @return New checksum context or NULL on error (e.g., if checksum size doesn't match algorithm)
6262
*/
6363
AWS_S3_API
64-
struct aws_s3_upload_request_checksum_context *aws_s3_upload_request_checksum_context_new_with_existing_checksum(
64+
struct aws_s3_upload_request_checksum_context *aws_s3_upload_request_checksum_context_new_with_existing_base64_checksum(
6565
struct aws_allocator *allocator,
6666
const struct aws_s3_meta_request_checksum_config_storage *checksum_config,
67-
struct aws_byte_cursor existing_checksum);
67+
struct aws_byte_cursor existing_base64_checksum);
6868

6969
/**
7070
* Acquire a reference to the upload request checksum context.

source/s3_auto_ranged_put.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static int s_process_part_info_synced(const struct aws_s3_part_info *info, void
155155

156156
if ((checksum_cur != NULL) && (checksum_cur->len > 0)) {
157157
/* Create checksum context with pre-calculated checksum */
158-
part->checksum_context = aws_s3_upload_request_checksum_context_new_with_existing_checksum(
158+
part->checksum_context = aws_s3_upload_request_checksum_context_new_with_existing_base64_checksum(
159159
auto_ranged_put->base.allocator, &auto_ranged_put->base.checksum_config, *checksum_cur);
160160
} else {
161161
part->checksum_context = aws_s3_upload_request_checksum_context_new(

source/s3_checksum_context.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,27 @@ struct aws_s3_upload_request_checksum_context *aws_s3_upload_request_checksum_co
5959
return context;
6060
}
6161

62-
struct aws_s3_upload_request_checksum_context *aws_s3_upload_request_checksum_context_new_with_existing_checksum(
62+
struct aws_s3_upload_request_checksum_context *aws_s3_upload_request_checksum_context_new_with_existing_base64_checksum(
6363
struct aws_allocator *allocator,
6464
const struct aws_s3_meta_request_checksum_config_storage *checksum_config,
65-
struct aws_byte_cursor existing_checksum) {
65+
struct aws_byte_cursor existing_base64_checksum) {
6666
struct aws_s3_upload_request_checksum_context *context =
6767
s_s3_upload_request_checksum_context_new_base(allocator, checksum_config);
6868
if (context) {
6969
/* Initial the buffer for checksum from the exist checksum */
70-
if (context->encoded_checksum_size != existing_checksum.len) {
70+
if (context->encoded_checksum_size != existing_base64_checksum.len) {
7171
struct aws_byte_cursor algo_name = aws_get_checksum_algorithm_name(context->algorithm);
7272
AWS_LOGF_ERROR(
7373
AWS_LS_S3_GENERAL,
7474
"Encoded checksum size mismatch during creating the context for algorithm " PRInSTR
7575
": expected %zu bytes, got %zu bytes",
7676
AWS_BYTE_CURSOR_PRI(algo_name),
7777
context->encoded_checksum_size,
78-
existing_checksum.len);
78+
existing_base64_checksum.len);
7979
aws_s3_upload_request_checksum_context_release(context);
8080
return NULL;
8181
}
82-
aws_byte_buf_init_copy_from_cursor(&context->base64_checksum, allocator, existing_checksum);
82+
aws_byte_buf_init_copy_from_cursor(&context->base64_checksum, allocator, existing_base64_checksum);
8383
context->checksum_calculated = true;
8484
}
8585
return context;

tests/s3_checksum_context_test.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ static int s_test_upload_request_checksum_context_get_checksum_cursor(struct aws
6464

6565
/* Test get checksum cursor with context that has calculated checksum */
6666
struct aws_byte_cursor existing_checksum = aws_byte_cursor_from_c_str("dGVzdA==");
67-
context = aws_s3_upload_request_checksum_context_new_with_existing_checksum(allocator, &config, existing_checksum);
67+
context =
68+
aws_s3_upload_request_checksum_context_new_with_existing_base64_checksum(allocator, &config, existing_checksum);
6869
ASSERT_NOT_NULL(context);
6970

7071
cursor = aws_s3_upload_request_checksum_context_get_checksum_cursor(context);
@@ -98,7 +99,8 @@ static int s_test_upload_request_checksum_context_error_cases(struct aws_allocat
9899
/* Test creation with mismatched checksum size */
99100
struct aws_byte_cursor wrong_size_checksum = aws_byte_cursor_from_c_str("short");
100101
struct aws_s3_upload_request_checksum_context *context =
101-
aws_s3_upload_request_checksum_context_new_with_existing_checksum(allocator, &config, wrong_size_checksum);
102+
aws_s3_upload_request_checksum_context_new_with_existing_base64_checksum(
103+
allocator, &config, wrong_size_checksum);
102104
ASSERT_NULL(context);
103105

104106
/* Test helper functions with NULL context */

0 commit comments

Comments
 (0)