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

View File

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