Fix renaming of .tmp files on Windows

On Windows, you can't rename over a file that exists, and you can't
delete a file you stil have open.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
This commit is contained in:
Paul "TBBle" Hampson 2024-08-13 00:40:02 +09:00
parent 8f4860f1d9
commit cce41cbd3f

View File

@ -197,6 +197,7 @@ If you want to contribute changes to a resolvers list, only edit files from the
else:
with open(md_path + ".tmp", "wt") as f:
f.write(out)
os.unlink(md_path)
os.rename(md_path + ".tmp", md_path)
# Legacy
@ -214,7 +215,8 @@ If you want to contribute changes to a resolvers list, only edit files from the
else:
with open(md_legacy_path + ".tmp", "wt") as f:
f.write(out_legacy)
os.rename(md_legacy_path + ".tmp", md_legacy_path)
os.unlink(md_legacy_path)
os.rename(md_legacy_path + ".tmp", md_legacy_path)
# Historic