Skip to content

Commit 484affe

Browse files
committed
Add argument to set temporary directory
1 parent 8e32dc3 commit 484affe

File tree

1 file changed

+17
-4
lines changed
  • web/client/codechecker_client/cli

1 file changed

+17
-4
lines changed

web/client/codechecker_client/cli/store.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,16 @@ def add_arguments_to_parser(parser):
270270
"match will be removed. You may also use Unix "
271271
"shell-like wildcards (e.g. '/*/jsmith/').")
272272

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.")
282+
273283
cmd_config.add_option(parser)
274284

275285
parser.add_argument('-f', '--force',
@@ -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

Comments
 (0)