Make sure we send the extra zeros in chunks

This commit is contained in:
Joseph Schorr 2014-10-14 15:58:52 -04:00
parent 3b88ba7373
commit efb3c6c494
2 changed files with 10 additions and 3 deletions

View file

@ -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)