Skip to content

Commit 85a57cd

Browse files
authored
chore: use tmp file when downloading driver (#2838)
1 parent e6c5ba4 commit 85a57cd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ def extractall(zip: zipfile.ZipFile, path: str) -> None:
9999

100100
def download_driver(zip_name: str) -> None:
101101
zip_file = f"playwright-{driver_version}-{zip_name}.zip"
102-
if os.path.exists("driver/" + zip_file):
102+
destination_path = "driver/" + zip_file
103+
if os.path.exists(destination_path):
103104
return
104105
url = "https://playwright.azureedge.net/builds/driver/"
105106
if (
@@ -109,9 +110,11 @@ def download_driver(zip_name: str) -> None:
109110
):
110111
url = url + "next/"
111112
url = url + zip_file
113+
temp_destination_path = destination_path + ".tmp"
112114
print(f"Fetching {url}")
113115
# Don't replace this with urllib - Python won't have certificates to do SSL on all platforms.
114-
subprocess.check_call(["curl", url, "-o", "driver/" + zip_file])
116+
subprocess.check_call(["curl", url, "-o", temp_destination_path])
117+
os.rename(temp_destination_path, destination_path)
115118

116119

117120
class PlaywrightBDistWheelCommand(BDistWheelCommand):

0 commit comments

Comments
 (0)