Database compression could lead to altered files. Use fsync before compressing to resolve this problem
This commit is contained in:
parent
038e485081
commit
a07fd14a35
1
iwla.py
1
iwla.py
|
@ -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')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user