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