Merge "Use extract_swift_bytes in override_bytes_from_content_type"

This commit is contained in:
Jenkins 2016-07-26 15:04:20 +00:00 committed by Gerrit Code Review
commit e7e9cfff68

View File

@ -3429,17 +3429,14 @@ def override_bytes_from_content_type(listing_dict, logger=None):
Takes a dict from a container listing and overrides the content_type, Takes a dict from a container listing and overrides the content_type,
bytes fields if swift_bytes is set. bytes fields if swift_bytes is set.
""" """
content_type, params = parse_content_type(listing_dict['content_type']) listing_dict['content_type'], swift_bytes = extract_swift_bytes(
for key, value in params: listing_dict['content_type'])
if key == 'swift_bytes': if swift_bytes is not None:
try: try:
listing_dict['bytes'] = int(value) listing_dict['bytes'] = int(swift_bytes)
except ValueError: except ValueError:
if logger: if logger:
logger.exception("Invalid swift_bytes") logger.exception("Invalid swift_bytes")
else:
content_type += ';%s=%s' % (key, value)
listing_dict['content_type'] = content_type
def clean_content_type(value): def clean_content_type(value):