mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 04:55:22 +03:00
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>
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user