summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2017-08-21 16:17:21 -0500
committerGunnar Mills <gmills@us.ibm.com>2017-08-30 11:29:12 -0500
commitb66b18cb1a4e9e29f70fce6a26a07e4abaf49e7d (patch)
treeb359239a64b813557df6401009182c6a944f69e8 /module
parent18c3a2422fcdd619da7017c3f636623e0df470d0 (diff)
downloadphosphor-rest-server-b66b18cb1a4e9e29f70fce6a26a07e4abaf49e7d.tar.gz
phosphor-rest-server-b66b18cb1a4e9e29f70fce6a26a07e4abaf49e7d.zip
Change ImageUpload to open file once
When uploading an image via REST without a file name, the image upload code closes the file twice, triggering the inotify twice. Resolves openbmc/openbmc#2174 Change-Id: I24ff920c745b865bb4e25468e1895b38abf4a592 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'module')
-rw-r--r--module/obmc/wsgi/apps/rest_dbus.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py
index 6560367..91f7f8c 100644
--- a/module/obmc/wsgi/apps/rest_dbus.py
+++ b/module/obmc/wsgi/apps/rest_dbus.py
@@ -684,19 +684,19 @@ class ImageUploadUtils:
if not filename:
handle, filename = tempfile.mkstemp(cls.file_suffix,
cls.file_prefix, cls.file_loc)
- os.close(handle)
else:
filename = os.path.join(cls.file_loc, filename)
-
+ handle = os.open(filename, os.O_WRONLY | os.O_CREAT)
try:
file_contents = request.body.read()
request.body.close()
- with open(filename, "w") as fd:
- fd.write(file_contents)
+ os.write(handle, file_contents)
except (IOError, ValueError), e:
abort(400, str(e))
except:
abort(400, "Unexpected Error")
+ finally:
+ os.close(handle)
class ImagePostHandler(RouteHandler):
OpenPOWER on IntegriCloud