mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-03 10:33:34 +00:00
Rollup merge of #80424 - jyn514:bootstrap-cleanup, r=Mark-Simulacrum
Don't give an error when creating a file for the first time Previously, `os.remove` would always give a FileNotFound error the first time you called it, causing bootstrap to make unnecessary copies. This now only calls `remove()` if the file exists, avoiding the unnecessary error. This is a pretty small cleanup but I think it's useful. Taken from https://github.com/rust-lang/rust/pull/79540.
This commit is contained in:
commit
1975142c97
@ -351,11 +351,13 @@ def output(filepath):
|
||||
with open(tmp, 'w') as f:
|
||||
yield f
|
||||
try:
|
||||
os.remove(filepath) # PermissionError/OSError on Win32 if in use
|
||||
os.rename(tmp, filepath)
|
||||
if os.path.exists(filepath):
|
||||
os.remove(filepath) # PermissionError/OSError on Win32 if in use
|
||||
except OSError:
|
||||
shutil.copy2(tmp, filepath)
|
||||
os.remove(tmp)
|
||||
return
|
||||
os.rename(tmp, filepath)
|
||||
|
||||
|
||||
class RustBuild(object):
|
||||
|
Loading…
Reference in New Issue
Block a user