Make sure we send the extra zeros in chunks
This commit is contained in:
parent
3b88ba7373
commit
efb3c6c494
2 changed files with 10 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
|||
from util.gzipwrap import GzipWrap
|
||||
from util.gzipwrap import GzipWrap, GZIP_BUFFER_SIZE
|
||||
from util.streamlayerformat import StreamLayerMerger
|
||||
from app import app
|
||||
|
||||
|
@ -75,7 +75,11 @@ def _import_format_generator(namespace, repository, tag, synthetic_image_id,
|
|||
# If the yielded size is less than the estimated size (which is likely), fill the rest with
|
||||
# zeros.
|
||||
if yielded_size < estimated_file_size:
|
||||
yield '\0' * (estimated_file_size - yielded_size)
|
||||
to_yield = estimated_file_size - yielded_size
|
||||
while to_yield > 0:
|
||||
yielded = min(to_yield, GZIP_BUFFER_SIZE)
|
||||
yield '\0' * yielded
|
||||
to_yield -= yielded
|
||||
|
||||
# Yield any file padding to 512 bytes that is necessary.
|
||||
yield _tar_file_padding(estimated_file_size)
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
from gzip import GzipFile
|
||||
|
||||
# 256K buffer to Gzip
|
||||
GZIP_BUFFER_SIZE = 1024 * 256
|
||||
|
||||
class GzipWrap(object):
|
||||
def __init__(self, input, filename=None, compresslevel=1):
|
||||
self.input = iter(input)
|
||||
|
@ -21,7 +24,7 @@ class GzipWrap(object):
|
|||
|
||||
input_size = 0
|
||||
input_buffer = ''
|
||||
while input_size < 1024 * 256: # 256K buffer to Gzip
|
||||
while input_size < GZIP_BUFFER_SIZE:
|
||||
try:
|
||||
s = self.input.next()
|
||||
input_buffer += s
|
||||
|
|
Reference in a new issue