Skip to content

Commit a108242

Browse files
committed
csmock: do not apply results limits twice
If the `--embed-context` feature is enabled, available and successful, there should be no reason to apply results limits again. This is an optimization that should not affect the results. Related: https://issues.redhat.com/browse/OSH-67
1 parent 801cec2 commit a108242

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

py/csmock

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ class ScanProps:
434434
self.cswrap_timeout = DEFAULT_CSWRAP_TIMEOUT
435435
self.embed_context = 0
436436
self.results_limits_opts = []
437+
self.results_limits_applied = False
437438
self.no_scan = False
438439
self.print_defects = False
439440
self.need_rpm_bi = False
@@ -1248,17 +1249,19 @@ cd %%s*/ || cd *\n\
12481249
cmd += f" <'{all_file}' >'{tmp_file}'"
12491250
if results.exec_cmd(cmd, shell=True) == 0:
12501251
shutil.move(tmp_file, all_file)
1252+
props.results_limits_applied = True
12511253

12521254
# we are done with mock
12531255

12541256
# make sure to apply results limits because `csgrep --embed-context` might not be available in chroot
1255-
if props.results_limits_opts:
1257+
if props.results_limits_opts and not props.results_limits_applied:
12561258
tmp_file = f"{all_file}.tmp"
12571259
csgrep_cmd = "csgrep --mode=json " + strlist_to_shell_cmd(props.results_limits_opts)
12581260
csgrep_cmd += f" '{all_file}' >'{tmp_file}'"
12591261
ec = results.exec_cmd(csgrep_cmd, shell=True)
12601262
if 0 == ec:
12611263
shutil.move(tmp_file, all_file)
1264+
props.results_limits_applied = True
12621265
else:
12631266
results.error("failed to apply results limits", ec=ec)
12641267

0 commit comments

Comments
 (0)