diff options
author | Jon Magrini <jmagrini@redhat.com> | 2016-01-19 09:36:51 -0500 |
---|---|---|
committer | Jon Magrini <jmagrini@redhat.com> | 2016-01-19 09:36:51 -0500 |
commit | b625f61a03d2127239480b45fed80028f82f8a50 (patch) | |
tree | e050011d57a1aee194706cbc6e55ad0c3dea2355 | |
parent | 903b61005f067e9d8c6f6e9d629d9caf0c29ac16 (diff) | |
download | rtslib-fb-b625f61a03d2127239480b45fed80028f82f8a50.tar.gz |
[rtslib-fb] Ensure internal buffers are flushed when saveconfig.json is written to disk. A power-outage, unexpected reboot, etc
can lead to zero byte file after a saveconfig.
Signed-off-by: Jon Magrini <jmagrini@redhat.com>
-rw-r--r-- | rtslib/root.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/rtslib/root.py b/rtslib/root.py index a4fbb2e..083a2c2 100644 --- a/rtslib/root.py +++ b/rtslib/root.py @@ -249,7 +249,9 @@ class RTSRoot(CFSNode): os.fchmod(f.fileno(), stat.S_IRUSR | stat.S_IWUSR) f.write(json.dumps(self.dump(), sort_keys=True, indent=2)) f.write("\n") + f.flush() os.fsync(f.fileno()) + f.close() os.rename(save_file+".temp", save_file) |