Skip to content

Commit

Permalink
Fix bug 891738
Browse files Browse the repository at this point in the history
Compute image size for the registry in the case where none is specified.

(cherry picked from commit 1f28b6c)

Change-Id: Ic21adf4865d0f481db9bd362cfaeeebd0942c974
  • Loading branch information
Paul Bourke authored and markmc committed Jan 5, 2012
1 parent 845646e commit 34aa896
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Authors
Expand Up @@ -23,6 +23,7 @@ Mark McLoughlin <markmc@redhat.com>
Matt Dietz <matt.dietz@rackspace.com>
Mike Lundy <mike@pistoncloud.com>
Monty Taylor <mordred@inaugust.com>
Paul Bourke <paul-david.bourke@hp.com>
Rick Clark <rick@openstack.org>
Rick Harris <rconradharris@gmail.com>
Russell Bryant <rbryant@redhat.com>
Expand Down
7 changes: 7 additions & 0 deletions glance/store/swift.py
Expand Up @@ -339,6 +339,13 @@ def add(self, image_id, image_file, image_size):
# best...
obj_etag = swift_conn.put_object(self.container, obj_name,
image_file)

if image_size == 0:
resp_headers = swift_conn.head_object(self.container,
obj_name)
# header keys are lowercased by Swift
if 'content-length' in resp_headers:
image_size = int(resp_headers['content-length'])
else:
# Write the image into Swift in chunks. We cannot
# stream chunks of the webob.Request.body_file, unfortunately,
Expand Down

0 comments on commit 34aa896

Please sign in to comment.