Shouldn't care when doing unlink on our temp files
if they exist or not. In fact this causes problems
when you do things like with tempfile/dir and happen
to try and unlink after it's already been removed.
This replaces these calls with the safer
common.fileutils.delete_if_exists which will
ignore the os exception of the object DNE.
Fixes bug:
1212502
Change-Id: Ica86c95f736411da486335aec5512e59247bfbc0
with fileutils.file_open(tmp) as image_file:
image_service.update(context, image_id, {}, image_file)
- os.unlink(tmp)
+ fileutils.delete_if_exists(tmp)
def is_xenserver_image(context, image_service, image_id):
tmp = create_temporary_file()
yield tmp
finally:
- os.unlink(tmp)
+ fileutils.delete_if_exists(tmp)
def temporary_dir():
chain = discover_vhd_chain(tempdir)
fix_vhd_chain(chain)
coalesced = coalesce_chain(chain)
- os.unlink(image_file)
+ fileutils.delete_if_exists(image_file)
rename_file(coalesced, image_file)