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 5bf21ed22b
commit ca1f261ee2
1 changed files with 2 additions and 0 deletions

View File

@ -281,6 +281,8 @@ class Controller(object):
with tempfile.NamedTemporaryFile() as tempf:
for chunk in blob_data:
tempf.write(chunk)
tempf.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