Fix bug 891738

Compute image size for the registry in the case where none is specified.

Change-Id: Ic21adf4865d0f481db9bd362cfaeeebd0942c974
This commit is contained in:
Paul Bourke 2011-11-21 16:50:23 +00:00
parent db10a10f55
commit 1f28b6ca7e
2 changed files with 8 additions and 0 deletions

View File

@ -24,6 +24,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>
Soren Hansen <soren.hansen@rackspace.com>

View File

@ -342,6 +342,13 @@ class Store(glance.store.base.Store):
# 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,