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:
parent
bcb8a06ef7
commit
97d0bc3f04
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user