@@ -269,6 +269,16 @@ def add_arguments_to_parser(parser):
269269 "If multiple prefixes are given, the longest "
270270 "match will be removed. You may also use Unix "
271271 "shell-like wildcards (e.g. '/*/jsmith/')." )
272+
273+ parser .add_argument ('--temp_dir' ,
274+ type = str ,
275+ metavar = 'PATH' ,
276+ required = False ,
277+ default = None ,
278+ dest = "temp_dir" ,
279+ help = "Specify a path to use as temporary folder "
280+ "useful when the folder containing the result folder "
281+ "is read only." )
272282
273283 cmd_config .add_option (parser )
274284
@@ -437,7 +447,8 @@ def assemble_zip(inputs,
437447 zip_file ,
438448 client ,
439449 prod_client ,
440- checker_labels : CheckerLabels ):
450+ checker_labels : CheckerLabels ,
451+ tmp_dir : str ):
441452 """Collect and compress report and source files, together with files
442453 contanining analysis related information into a zip file which
443454 will be sent to the server.
@@ -507,7 +518,7 @@ def assemble_zip(inputs,
507518 file_paths .update (report .original_files )
508519 file_report_positions [report .file .original_path ].add (report .line )
509520
510- temp_dir = tempfile .mkdtemp ('-unique-plists' , dir = inputs [ 0 ] )
521+ temp_dir = tempfile .mkdtemp ('-unique-plists' , dir = tmp_dir )
511522 for dirname , analyzer_reports in unique_reports .items ():
512523 for analyzer_name , reports in analyzer_reports .items ():
513524 if not analyzer_name :
@@ -909,8 +920,9 @@ def main(args):
909920 port ,
910921 product_name = product_name )
911922
923+ temp_dir_path : str = args .temp_dir if args .temp_dir else args .input [0 ]
912924 try :
913- temp_dir = tempfile .mkdtemp (suffix = "-store" , dir = args . input [ 0 ] )
925+ temp_dir = tempfile .mkdtemp (suffix = "-store" , dir = temp_dir_path )
914926 LOG .debug (f"{ temp_dir } directory created successfully!" )
915927 except PermissionError :
916928 LOG .error (f"Permission denied! You do not have sufficient "
@@ -930,7 +942,8 @@ def main(args):
930942 zip_file ,
931943 client ,
932944 prod_client ,
933- context .checker_labels )
945+ context .checker_labels ,
946+ temp_dir_path )
934947 except ReportLimitExceedError :
935948 sys .exit (1 )
936949 except Exception as ex :
0 commit comments