Merge "Return size as int from store get call"
This commit is contained in:
commit
2857f1426a
@ -155,7 +155,7 @@ class Store(glance.store.base.Store):
|
||||
msg = _("Found image at %s. Returning in ChunkedFile.") % filepath
|
||||
LOG.debug(msg)
|
||||
try:
|
||||
image_size = str(os.path.getsize(filepath))
|
||||
image_size = int(os.path.getsize(filepath))
|
||||
except os.error:
|
||||
image_size = None
|
||||
return (ChunkedFile(filepath), image_size)
|
||||
|
@ -177,7 +177,7 @@ class Store(glance.store.base.Store):
|
||||
image_id=location.image_id,
|
||||
store_specs=location.store_specs)
|
||||
return self._query(new_loc, verb, depth + 1)
|
||||
content_length = resp.getheader('content-length', 0)
|
||||
content_length = int(resp.getheader('content-length', 0))
|
||||
return (conn, resp, content_length)
|
||||
|
||||
def _get_conn_class(self, loc):
|
||||
|
@ -305,7 +305,7 @@ class Store(glance.store.base.Store):
|
||||
except StopIteration:
|
||||
return ''
|
||||
|
||||
length = resp_headers.get('content-length')
|
||||
length = int(resp_headers.get('content-length', 0))
|
||||
return (ResponseIndexable(resp_body, length), length)
|
||||
|
||||
def get_size(self, location):
|
||||
|
@ -79,7 +79,7 @@ class BaseTestCase(object):
|
||||
image_id=image_id)
|
||||
|
||||
(get_iter, get_size) = store.get(location)
|
||||
self.assertEqual('3', get_size)
|
||||
self.assertEqual(3, get_size)
|
||||
self.assertEqual('XXX', ''.join(get_iter))
|
||||
|
||||
store.delete(location)
|
||||
@ -96,5 +96,5 @@ class BaseTestCase(object):
|
||||
store.get_store_location_class(),
|
||||
uri=image_uri)
|
||||
(get_iter, get_size) = store.get(location)
|
||||
self.assertEqual('3', get_size)
|
||||
self.assertEqual(3, get_size)
|
||||
self.assertEqual('XXX', ''.join(get_iter))
|
||||
|
@ -221,7 +221,7 @@ class TestSwiftStore(store_tests.BaseTestCase, unittest.TestCase):
|
||||
# Store interface should still be respected even though
|
||||
# we are storing images in multiple Swift objects
|
||||
(get_iter, get_size) = store.get(location)
|
||||
self.assertEqual('5242880', get_size)
|
||||
self.assertEqual(5242880, get_size)
|
||||
self.assertEqual('X' * 5242880, ''.join(get_iter))
|
||||
|
||||
# The object should have a manifest pointing to the chunks
|
||||
@ -332,7 +332,7 @@ class TestSwiftStore(store_tests.BaseTestCase, unittest.TestCase):
|
||||
self.assertEqual('', container.get('x-container-write', ''))
|
||||
|
||||
(get_iter, get_size) = store.get(location)
|
||||
self.assertEqual('3', get_size)
|
||||
self.assertEqual(3, get_size)
|
||||
self.assertEqual('XXX', ''.join(get_iter))
|
||||
|
||||
store.delete(location)
|
||||
|
Loading…
Reference in New Issue
Block a user