Meta: Make download_file work on Windows

The file is not committed to disk until the close which occurs at the
termination of the scope. Extract the `rename` to outside the scope
allowing this to work on Windows. The `download_file` utility downloads
a file in the `gn` build.
This commit is contained in:
Saleem Abdulrasool 2024-09-18 11:24:49 -07:00 committed by Andrew Kaster
parent fbc941d4f4
commit 199f0e45cb
Notes: github-actions[bot] 2024-09-25 16:20:35 +00:00

View file

@ -70,7 +70,7 @@ def main():
try:
with tempfile.NamedTemporaryFile(delete=False, dir=output_file.parent) as out:
out.write(f.read())
os.rename(out.name, output_file)
os.rename(out.name, output_file)
except IOError:
os.unlink(out.name)