Database compression could lead to altered files. Use fsync before compressing to resolve this problem

This commit is contained in:
Gregory Soutade 2017-01-29 09:13:32 +01:00
parent 038e485081
commit a07fd14a35
1 changed files with 1 additions and 0 deletions

View File

@ -249,6 +249,7 @@ class IWLA(object):
with open(filename + '.tmp', 'wb+') as f, self._openDB(filename, 'w') as fzip:
pickle.dump(obj, f)
os.fsync(f)
f.seek(0)
fzip.write(f.read())
os.remove(filename + '.tmp')