Use replace instead of rename in localetools.py
On Unix, if target exists and it is a file, rename silently replaces it if the user has permission. However, on Windows, if the target exists, FileExistError will be raised. With replace, if target points to an existing file or empty directory, it will be unconditionally replaced. Change-Id: I2774152fec78a00c4ca6c9d1b927e503df2f2e84 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit eff8e6b885dfa3f26523ca39164725b4932c31bd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
d8e1416977
commit
9709c4f842
@ -99,7 +99,7 @@ def AtomicRenameTemporaryFile(originalLocation: Path, *, prefix: str, dir: Path)
|
||||
yield tempFile
|
||||
tempFile.close()
|
||||
# Move the modified file to the original location
|
||||
Path(tempFile.name).rename(originalLocation)
|
||||
Path(tempFile.name).replace(originalLocation)
|
||||
except Exception:
|
||||
# delete the temporary file in case of error
|
||||
tempFile.close()
|
||||
|
Loading…
x
Reference in New Issue
Block a user