@@ -90,26 +90,31 @@ def main(version: str = "latest") -> None:
90
90
destination_dir = os .path .expanduser ("~/.local/bin" )
91
91
os .makedirs (destination_dir , exist_ok = True )
92
92
93
- # Download the binary to a temporary folder
94
- with tempfile .TemporaryDirectory () as tmp_dir :
95
- tmp_file = os .path .join (tmp_dir , "airbyte-ci" )
93
+ # Set the path of the versioned binary
94
+ versioned_path = os .path .join (destination_dir , f"airbyte-ci-{ version } " )
96
95
96
+ # If the version is not explicit, delete any existing versioned binary
97
+ if version == "latest" and os .path .exists (versioned_path ):
98
+ os .remove (versioned_path )
99
+
100
+ # Download the versioned binary if it doesn't exist
101
+ if not os .path .exists (versioned_path ):
97
102
# Download the file using urllib.request
98
103
print (f"Downloading from { url } " )
99
104
ssl_context = get_ssl_context ()
100
- with urllib .request .urlopen (url , context = ssl_context ) as response , open (tmp_file , "wb" ) as out_file :
105
+ with urllib .request .urlopen (url , context = ssl_context ) as response , open (versioned_path , "wb" ) as out_file :
101
106
shutil .copyfileobj (response , out_file )
102
107
103
- # Check if the destination path is a symlink and delete it if it is
104
- destination_path = os .path .join (destination_dir , "airbyte-ci" )
105
- if os .path .islink (destination_path ):
106
- os .remove (destination_path )
108
+ # Make the versioned binary executable
109
+ os .chmod (versioned_path , 0o755 )
107
110
108
- # Copy the file from the temporary folder to the destination
109
- shutil .copy (tmp_file , destination_path )
111
+ # Ensure that the destination path does not exist.
112
+ destination_path = os .path .join (destination_dir , "airbyte-ci" )
113
+ if os .path .exists (destination_path ):
114
+ os .remove (destination_path )
110
115
111
- # Make the binary executable
112
- os .chmod ( destination_path , 0o755 )
116
+ # Symlink the versioned binary to the destination path
117
+ os .symlink ( versioned_path , destination_path )
113
118
114
119
# ASCII Art and Completion Message
115
120
install_complete_message = f"""
0 commit comments