Compute the tarsum only when required. Newer versions of Docker only require the simple SHA256 checksum, so this should save us from writing to a temp file.
This commit is contained in:
parent
28a463f998
commit
47be7cab7a
2 changed files with 33 additions and 14 deletions
|
@ -13,7 +13,8 @@ CHUNK_SIZE = 5 * 1024 * 1024
|
|||
|
||||
class SizeInfo(object):
|
||||
def __init__(self):
|
||||
self.size = 0
|
||||
self.uncompressed_size = 0
|
||||
self.compressed_size = 0
|
||||
|
||||
def calculate_size_handler():
|
||||
""" Returns an object and a SocketReader handler. The handler will gunzip the data it receives,
|
||||
|
@ -28,8 +29,10 @@ def calculate_size_handler():
|
|||
# Note: We set a maximum CHUNK_SIZE to prevent the decompress from taking too much
|
||||
# memory. As a result, we have to loop until the unconsumed tail is empty.
|
||||
current_data = buf
|
||||
size_info.compressed_size += len(current_data)
|
||||
|
||||
while len(current_data) > 0:
|
||||
size_info.size += len(decompressor.decompress(current_data, CHUNK_SIZE))
|
||||
size_info.uncompressed_size += len(decompressor.decompress(current_data, CHUNK_SIZE))
|
||||
current_data = decompressor.unconsumed_tail
|
||||
|
||||
return size_info, fn
|
||||
|
|
Reference in a new issue