@@ -559,7 +559,7 @@ def generate_instructions(self) -> str:
559559 return instructions
560560
561561 def create_list_of_cert_and_artifacts (self , actions , ca_cert_filename_on_usb ):
562- # Move the newly created certificate and it's associated artifacts to the
562+ # Move the newly created certificate, and it's associated artifacts to the
563563 # certs_issued directory
564564 if len ([x for x in self .usb_path .glob ("*.crt" ) if x not in actions ]) == 0 :
565565 print (
@@ -585,6 +585,10 @@ def create_list_of_cert_and_artifacts(self, actions, ca_cert_filename_on_usb):
585585 certs_issued_destination = (
586586 self .repo_dir / "certs_issued" / Path (ca_cert_filename_on_usb ).stem
587587 )
588+ if (
589+ not certs_issued_destination .exists ()
590+ ) and certs_issued_destination not in actions :
591+ result .update ({certs_issued_destination : "mkdir" })
588592 result .update ({x : certs_issued_destination for x in expected_cert_files })
589593 return result
590594
@@ -625,19 +629,20 @@ def process_usb_files(self, actions):
625629 for x in displayed_actions .keys ()
626630 )
627631 )
628- if Confirm .ask (
629- "[q]Would you like to perform these move and delete actions?[/q]"
630- ):
631- for source_file in actions :
632- if actions [source_file ] == "delete" :
633- source_file .unlink ()
634- print (f"Deleted { source_file } " )
635- elif issubclass (type (actions [source_file ]), PurePath ):
636- shutil .copy2 (source_file , actions [source_file ] / source_file .name )
637- source_file .unlink ()
638- print (f"Moved { source_file } to { actions [source_file ]} " )
639- elif actions [source_file ] == "ignore" :
640- print (f"Ignored { source_file } " )
632+ if Confirm .ask ("[q]Would you like to perform these actions?[/q]" ):
633+ for filename in actions :
634+ if actions [filename ] == "delete" :
635+ filename .unlink ()
636+ print (f"Deleted { filename } " )
637+ elif actions [filename ] == "mkdir" :
638+ filename .mkdir ()
639+ print (f"Created { filename } " )
640+ elif issubclass (type (actions [filename ]), PurePath ):
641+ shutil .copy2 (filename , actions [filename ] / filename .name )
642+ filename .unlink ()
643+ print (f"Moved { filename } to { actions [filename ]} " )
644+ elif actions [filename ] == "ignore" :
645+ print (f"Ignored { filename } " )
641646
642647
643648def set_default_click_arguments_from_config (
@@ -800,7 +805,7 @@ def pull_from_stick(
800805 """
801806 orchestrator = HsmOrchestrator (orchestrator_config_filename , repo_dir = repo_dir )
802807 orchestrator .choose_usb_disk ()
803- actions = {}
808+ actions = {} # Key is the file and value is the action to perform on that file
804809 ca_cert_files_in_repo = {}
805810 for private_key_directory in [
806811 x
0 commit comments