settings: write settings to disk robustly
commit81cee505c4b58c9f096d2077dc848c9b5f299c75
authorDavid Aguilar <davvid@gmail.com>
Fri, 28 Oct 2022 06:56:11 +0000 (27 23:56 -0700)
committerDavid Aguilar <davvid@gmail.com>
Fri, 28 Oct 2022 06:56:25 +0000 (27 23:56 -0700)
treea53f85e67e83f9ae3b81c6fa51aa2ccc6d6625a6
parent042e8c014e576e54e7a41456d859cdbf652dac95
settings: write settings to disk robustly

Write settings to a .tmp file and then atomically rename the files into
place to avoid data loss during a system shutdown.

We sync data to disk before deleting the .bak file so that we can
recover data in the event that the settings were not flushed to disk.

Closes #1241
Reported-by: Matias N. Goldberg @darksylinc via github.com
Signed-off-by: David Aguilar <davvid@gmail.com>
CHANGES.rst
cola/core.py
cola/settings.py