repository: use os.replace instead of os.rename

On Windows, os.rename raises an exception if the destination file already exists, unlike os.replace which replaces the destination file.

Docs:
https://docs.python.org/3/library/os.html#os.rename
https://docs.python.org/3/library/os.html#os.replace
This commit is contained in:
Rayyan Ansari 2022-11-10 17:56:45 +00:00
parent 5090f809ec
commit 62341673c1
1 changed files with 1 additions and 1 deletions

View File

@ -636,7 +636,7 @@ class Repository:
os.fsync(fd.fileno()) os.fsync(fd.fileno())
def rename_tmp(file): def rename_tmp(file):
os.rename(file + ".tmp", file) os.replace(file + ".tmp", file)
hints = { hints = {
"version": 2, "version": 2,