os.replace is not atomic on Windows
https://github.com/eight04/ComicCrawler/blob/7ad079af4c8190837afa505cffe3b98cdce888e0/comiccrawler/io.py#L59-L60 https://docs.python.org/3/library/os.html#os.rename
I think we should change the procedure to:
- Rename the old file.
- Write new file.
- Delete the old file.
So it doesn't depend on os.replace.
Actually, the current strategy is same as other libraries.
_write_atomic from std importlab uses tempfile + os.replace:
https://github.com/python/cpython/blob/9e2be60634914f23db2ae5624e4acc9335bf5fea/Lib/importlib/_bootstrap_external.py#L105-L124
os.replace in cpython uses MoveFileExW:
https://github.com/python/cpython/blob/48e8c82fc63d2ddcddce8aa637a892839b551619/Modules/posixmodule.c#L4056
_replace_atomic from atomicwrites uses MoveFileExW:
https://github.com/untitaker/python-atomicwrites/blob/a01f2ee2be5d86a066422a652705ee9394c472e5/atomicwrites/init.py#L68-L72
Let's see if there are more data loss reports.