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 commit is contained in:
parent
dc6121ca68
commit
7ac02bddc7
1 changed files with 4 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue