@@ -5079,16 +5079,18 @@ def _validate_and_install_local(yaml_path: Path, source_label: str) -> None:
50795079 if archive_fmt in ("tar.gz" , "zip" ):
50805080 # Extract workflow.yml from the archive.
50815081 suffix = ".tar.gz" if archive_fmt == "tar.gz" else ".zip"
5082+ arc_tmp_path = None
50825083 with tempfile .NamedTemporaryFile (suffix = suffix , delete = False ) as arc_tmp :
5083- arc_tmp .write (raw_data )
50845084 arc_tmp_path = Path (arc_tmp .name )
5085+ arc_tmp .write (raw_data )
50855086 try :
50865087 wf_yaml = _extract_workflow_yml (arc_tmp_path , archive_fmt )
50875088 with tempfile .NamedTemporaryFile (suffix = ".yml" , delete = False ) as tmp :
5088- tmp .write (wf_yaml )
50895089 tmp_path = Path (tmp .name )
5090+ tmp .write (wf_yaml )
50905091 finally :
5091- arc_tmp_path .unlink (missing_ok = True )
5092+ if arc_tmp_path is not None :
5093+ arc_tmp_path .unlink (missing_ok = True )
50925094 else :
50935095 # Treat as a plain YAML file (existing behaviour).
50945096 with tempfile .NamedTemporaryFile (suffix = ".yml" , delete = False ) as tmp :
@@ -5125,9 +5127,10 @@ def _validate_and_install_local(yaml_path: Path, source_label: str) -> None:
51255127 console .print (f"[red]Error:[/red] Failed to extract workflow from archive: { exc } " )
51265128 raise typer .Exit (1 )
51275129 import tempfile
5130+ tmp_local = None
51285131 with tempfile .NamedTemporaryFile (suffix = ".yml" , delete = False ) as tmp :
5129- tmp .write (wf_yaml )
51305132 tmp_local = Path (tmp .name )
5133+ tmp .write (wf_yaml )
51315134 try :
51325135 _validate_and_install_local (tmp_local , str (source_path ))
51335136 finally :
@@ -5231,13 +5234,15 @@ def _validate_and_install_local(yaml_path: Path, source_label: str) -> None:
52315234 if cat_archive_fmt in ("tar.gz" , "zip" ):
52325235 # Download URL points to an archive — extract workflow.yml from it.
52335236 suffix = ".tar.gz" if cat_archive_fmt == "tar.gz" else ".zip"
5237+ arc_tmp = None
52345238 with tempfile .NamedTemporaryFile (suffix = suffix , delete = False ) as arc_f :
5235- arc_f .write (raw_response )
52365239 arc_tmp = Path (arc_f .name )
5240+ arc_f .write (raw_response )
52375241 try :
52385242 wf_yaml_bytes = _extract_workflow_yml (arc_tmp , cat_archive_fmt )
52395243 finally :
5240- arc_tmp .unlink (missing_ok = True )
5244+ if arc_tmp is not None :
5245+ arc_tmp .unlink (missing_ok = True )
52415246 workflow_file .write_bytes (wf_yaml_bytes )
52425247 else :
52435248 workflow_file .write_bytes (raw_response )
0 commit comments