@@ -82,7 +82,6 @@ def deploy(
8282 artifact_path : Union [Path , str ],
8383 properties : Optional [Dict [str , List [str ]]] = None ,
8484 checksum_enabled : bool = False ,
85- checksum_algorithms : Optional [List [str ]] = None ,
8685 ) -> ArtifactInfoResponse :
8786 """
8887 Deploy a file or directory.
@@ -99,30 +98,22 @@ def deploy(
9998 for file in files :
10099 self .deploy (Path (f"{ root } /{ file } " ), Path (f"{ new_root } /{ file } " ), properties , checksum_enabled )
101100 else :
102- checksum_headers : Dict [str , str ] = {}
103-
104- if checksum_enabled :
105- checksum_headers ["X-Checksum-Deploy" ] = "true"
106- checksum_algorithms = ["sha1" , "sha256" , "md5" ]
107-
108- if checksum_algorithms is not None :
109- artifact_check_sums = Checksums .generate (local_file , checksum_algorithms )
110- if artifact_check_sums .md5 :
111- checksum_headers ["X-Checksum" ] = artifact_check_sums .md5
112- if artifact_check_sums .sha1 :
113- checksum_headers ["X-Checksum-Sha1" ] = artifact_check_sums .sha1
114- if artifact_check_sums .sha256 :
115- checksum_headers ["X-Checksum-Sha256" ] = artifact_check_sums .sha256
116-
101+ properties_param_str = ""
102+ if properties is not None :
103+ properties_param_str = self ._format_properties (properties )
104+ route = ";" .join (s for s in [artifact_folder .as_posix (), properties_param_str ] if s )
105+ artifact_check_sums = Checksums .generate (local_file )
106+ headers = {
107+ "X-Checksum-Sha1" : artifact_check_sums .sha1 ,
108+ "X-Checksum-Sha256" : artifact_check_sums .sha256 ,
109+ "X-Checksum" : artifact_check_sums .md5 ,
110+ }
117111 if checksum_enabled :
112+ headers ["X-Checksum-Deploy" ] = "true"
118113 try :
119- properties_param_str = ""
120- if properties is not None :
121- properties_param_str = self ._format_properties (properties )
122- route = ";" .join (s for s in [artifact_folder .as_posix (), properties_param_str ] if s )
123114 self ._put (
124115 route = route ,
125- headers = checksum_headers ,
116+ headers = headers ,
126117 )
127118 except requests .exceptions .HTTPError as error :
128119 if error .response .status_code == 404 :
@@ -135,11 +126,7 @@ def deploy(
135126 raise ArtifactoryError from error
136127 else :
137128 with local_file .open ("rb" ) as stream :
138- properties_param_str = ""
139- if properties is not None :
140- properties_param_str = self ._format_properties (properties )
141- route = ";" .join (s for s in [artifact_folder .as_posix (), properties_param_str ] if s )
142- self ._put (route = route , headers = checksum_headers , data = stream )
129+ self ._put (route = route , headers = headers , data = stream )
143130
144131 logger .debug ("Artifact %s successfully deployed" , local_file )
145132 return self .info (artifact_folder )
0 commit comments