diff options
| author | NODA, Kai <nodakai@gmail.com> | 2018-06-27 03:23:14 +0800 |
|---|---|---|
| committer | NODA, Kai <nodakai@gmail.com> | 2018-07-10 22:50:20 +0800 |
| commit | 97d0bc3f044a2f105ec760f78da800a1e44c8f05 (patch) | |
| tree | 3fa90c60879fa14c8f7e0c6b9e7eadc5bcaf24e4 /src/bootstrap/bootstrap.py | |
| parent | bcb8a06ef7929417f09ed5055692d8afc59b3c70 (diff) | |
| download | rust-97d0bc3f044a2f105ec760f78da800a1e44c8f05.tar.gz rust-97d0bc3f044a2f105ec760f78da800a1e44c8f05.zip | |
bootstrap: our best to achieve atomic rename on Win32
This is a tricky operation to implement on Win32; see https://ci.appveyor.com/project/nodakai/python-win-behavior Signed-off-by: NODA, Kai <nodakai@gmail.com>
Diffstat (limited to 'src/bootstrap/bootstrap.py')
| -rw-r--r-- | src/bootstrap/bootstrap.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index d1aa32236ae..71c1c61e3d9 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -308,7 +308,12 @@ def output(filepath): tmp = filepath + '.tmp' with open(tmp, 'w') as f: yield f - os.rename(tmp, filepath) + try: + os.remove(filepath) # PermissionError/OSError on Win32 if in use + os.rename(tmp, filepath) + except OSError: + shutil.copy2(tmp, filepath) + os.remove(tmp) class RustBuild(object): |
