Skip to content

Commit

Permalink
fixes bug698318.
Browse files Browse the repository at this point in the history
Work done by Ewan Mellor; I just fixed a conflict after merging trunk...
  • Loading branch information
[email protected] committed Jan 13, 2011
2 parents 1f4a644 + b2cd2b0 commit 18d6cf8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion glance/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _upload(self, req, image_meta):
registry.update_image_metadata(image_meta['id'], image_meta)

try:
location = store.add(image_meta['id'], req.body)
location = store.add(image_meta['id'], req.body_file)
return location
except exception.Duplicate, e:
logging.error("Error adding image to store: %s", str(e))
Expand Down
11 changes: 7 additions & 4 deletions glance/store/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def add(cls, id, data):
FLAGS.filesystem_store_datadir and <ID> is the supplied image ID.
:param id: The opaque image identifier
:param data: The image data to write
:param data: The image data to write, as a file-like object
:retval The location that was written, with file:// scheme prepended
"""
Expand All @@ -125,8 +125,11 @@ def add(cls, id, data):
raise exception.Duplicate("Image file %s already exists!"
% filepath)

f = open(filepath, 'wb')
f.write(data)
f.close()
with open(filepath, 'wb') as f:
while True:
buf = data.read(ChunkedFile.CHUNKSIZE)
if not buf:
break
f.write(buf)

return 'file://%s' % filepath

0 comments on commit 18d6cf8

Please sign in to comment.