@@ -268,26 +268,24 @@ def artifact_to_metadata_artifact(filename: str, artifact: Artifact) -> Artifact
268268 if not filename .endswith (".whl" ):
269269 return None
270270
271- with tempfile .TemporaryDirectory (dir = settings .WORKING_DIRECTORY ) as temp_dir_name :
272- with tempfile .NamedTemporaryFile (dir = temp_dir_name , suffix = filename ) as temp_file :
273- artifact .file .seek (0 )
274- shutil .copyfileobj (artifact .file , temp_file )
275- temp_file .flush ()
276- metadata_content = extract_wheel_metadata (temp_file .name )
277- if not metadata_content :
278- return None
279-
280- with tempfile .NamedTemporaryFile (dir = temp_dir_name , suffix = ".metadata" ) as temp_md :
281- temp_md .write (metadata_content )
282- temp_md .flush ()
283- metadata_artifact = Artifact .init_and_validate (temp_md .name )
284- try :
285- metadata_artifact .save ()
286- except IntegrityError :
287- metadata_artifact = Artifact .objects .get (
288- sha256 = metadata_artifact .sha256 , pulp_domain = get_domain ()
289- )
290- return metadata_artifact
271+ with tempfile .NamedTemporaryFile ("wb" , suffix = filename ) as temp_file :
272+ artifact .file .seek (0 )
273+ shutil .copyfileobj (artifact .file , temp_file )
274+ temp_file .flush ()
275+ metadata_content = extract_wheel_metadata (temp_file .name )
276+ if not metadata_content :
277+ return None
278+ with tempfile .NamedTemporaryFile (suffix = ".metadata" ) as metadata_temp :
279+ metadata_temp .write (metadata_content )
280+ metadata_temp .flush ()
281+ metadata_artifact = Artifact .init_and_validate (metadata_temp .name )
282+ try :
283+ metadata_artifact .save ()
284+ except IntegrityError :
285+ metadata_artifact = Artifact .objects .get (
286+ sha256 = metadata_artifact .sha256 , pulp_domain = get_domain ()
287+ )
288+ return metadata_artifact
291289
292290
293291def fetch_json_release_metadata (name : str , version : str , remotes : set [Remote ]) -> dict :
0 commit comments