Skip to content

Commit

Permalink
Fix renaming of .tmp files on Windows
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
TBBle committed Aug 12, 2024
1 parent 7aacac1 commit 3879541
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion utils/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def process(md_path, signatures_to_update):
else:
with open(md_path + ".tmp", "wt") as f:
f.write(out)
os.unlink(md_path)
os.rename(md_path + ".tmp", md_path)

# Legacy
Expand All @@ -214,7 +215,8 @@ def process(md_path, signatures_to_update):
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

Expand Down

0 comments on commit 3879541

Please sign in to comment.