Forced flush of tmp file to disk on ui retrieval

UI retrieval routine loads the package's temporary file  from disk
to properly render its ui. This procedure does not close the file
before reading it, so the write buffers should be flushed first.

This was causing the bug when the UI could not be properly fetched
from the API.

Change-Id: I53cd08945c826dd18a7308f9f007d50241bb9041
Closes-bug: #1565805
This commit is contained in:
Alexander Tivelkov 2016-05-24 18:45:59 +03:00
parent 0355244123
commit 623ebce812

@ -287,6 +287,8 @@ class Controller(object):
with tempfile.NamedTemporaryFile() as tempf:
for chunk in blob_data:
tempf.write(chunk)
tempf.file.flush()
os.fsync(tempf.file.fileno())
with load_utils.load_from_file(tempf.name, target_dir=None,
drop_dir=True) as pkg:
return pkg.ui