Skip to content

Commit

Permalink
Fix LP Bug#885696 two issues with checked_iter
Browse files Browse the repository at this point in the history
 The error message raised by IOError needed %locals() added

 If there is no cache in the pipeline image_meta['size'] appears to be of
 type str on my system. Thus the compare of expected_size and bytes_written
 always failed even when the values should have matched.
 Unconditionally convert expected_size to int to resolve this.
 Curiously image_meta['size'] is of type int if the cache is in the pipeline.
 This latter fix could be removed if the typing is resolved

Change-Id: I05eadce2b5ceb8eb7939acb41668aff089270e21
  • Loading branch information
Tomas Hancock committed Nov 3, 2011
1 parent bc7aeb4 commit 2674e8b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions glance/api/v1/images.py
Expand Up @@ -674,10 +674,11 @@ def checked_iter(image_id, expected_size, image_iter):
"bytes") % locals()
logger.error(msg)
raise IOError(errno.EPIPE, _("Corrupt image download for "
"image %(image_id)s"))
"image %(image_id)s") % locals())

image_iter = result['image_iterator']
expected_size = image_meta['size']
# image_meta['size'] is a str
expected_size = int(image_meta['size'])
response.app_iter = checked_iter(image_id, expected_size, image_iter)
# Using app_iter blanks content-length, so we set it here...
response.headers['Content-Length'] = image_meta['size']
Expand Down

0 comments on commit 2674e8b

Please sign in to comment.