Skip to content

Commit c3b2220

Browse files
committed
add comments
1 parent 7fc465e commit c3b2220

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

localstack-core/localstack/services/s3/checksums.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Code ported/inspired from https://github.com/aliyun/aliyun-oss-python-sdk/blob/master/oss2/crc64_combine.py
2-
# MIT licensed
2+
# This code implements checksum combinations: the ability to get the full checksum of an object with the checksums of
3+
# its parts.
34
import sys
45

56
_CRC64NVME_POLYNOMIAL = 0xAD93D23594C93659
@@ -129,6 +130,17 @@ def _verify_params(size_bits: int, init_crc: int, xor_out: int):
129130

130131

131132
def create_combine_function(poly: int, size_bits: int, init_crc=~0, rev=True, xor_out=0):
133+
"""
134+
The function returns the proper function depending on the checksum algorithm wanted.
135+
Example, for the CRC64NVME function, you need to pass the proper polynomial, its size (64), and the proper XOR_OUT
136+
(taken for the botocore/httpchecksums.py file).
137+
:param poly: the CRC polynomial used (each algorithm has its own, for ex. CRC32C is called Castagnioli)
138+
:param size_bits: the size of the algorithm, 32 for CRC32 and 64 for CRC64
139+
:param init_crc: the init_crc, always 0 in our case
140+
:param rev: reversing the polynomial, true in our case as well
141+
:param xor_out: value used to initialize the register as we don't specify init_crc
142+
:return:
143+
"""
132144
size_bits, init_crc, xor_out = _verify_params(size_bits, init_crc, xor_out)
133145

134146
mask = (1 << size_bits) - 1

localstack-core/localstack/services/s3/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,6 @@ def complete_multipart(
496496
checksum_hash = CombinedCrcHash(self.object.checksum_algorithm)
497497

498498
pos = 0
499-
_checksum_value = 0
500499
parts_map = {}
501500
for index, part in enumerate(parts):
502501
part_number = part["PartNumber"]

0 commit comments

Comments
 (0)