Skip to content

Commit 2bb4aae

Browse files
authored
Merge pull request #16 from scality/cleaning-temp-dir
clean temp directories to avoid errors when running multiple times
2 parents 2ab91d9 + e688530 commit 2bb4aae

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""This module is the main core of this github action"""
33

44
import os
5+
from shutil import rmtree
56
from lib.detect import detect_target_type
67
from lib.install import install
78
from lib.scan import ScanCommand
@@ -164,6 +165,12 @@
164165
sbom_format=SBOM_FORMAT,
165166
)
166167
scan_command.execute()
168+
# Delete the converted images
169+
# This is done to avoid errors and scanning again same
170+
# images when the action is run multiple times
171+
if os.path.isdir(CONVERT_DIR):
172+
rmtree(CONVERT_DIR, ignore_errors=True)
173+
print(f"Deleted {CONVERT_DIR}")
167174

168175
if VULN_REPORT:
169176
generate_vuln_report(OUTPUT_DIR)

0 commit comments

Comments
 (0)