If we've just truncated/created the file to receive
the download, but the download fails, then delete the file.
Otherwise subsequent downloads would not be attempted.
Change-Id: Ibe9ba199b2f424d570ce7aedfb768ce283816a3b
# checked before we got here.
(image_service, image_id) = nova.image.get_image_service(context,
image_href)
- with open(path, "wb") as image_file:
- metadata = image_service.get(context, image_id, image_file)
+ try:
+ with open(path, "wb") as image_file:
+ metadata = image_service.get(context, image_id, image_file)
+ except Exception:
+ os.unlink(path)
+ raise
return metadata