Skip to content

Commit d7626bf

Browse files
committed
Fix absolute path related bugs
1 parent 6b5a414 commit d7626bf

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/fosslight_scanner/common.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,12 @@ def create_scancodejson(final_report, output_extension, ui_mode_report, src_path
210210

211211
oss_total_list = []
212212
root_dir = ""
213-
213+
root_strip = ""
214214
try:
215-
parent = os.path.basename(os.path.abspath(src_path))
216-
two_depth_parent = os.path.basename(Path(os.path.abspath(src_path)).parents[0])
215+
src_path = os.path.abspath(src_path)
216+
parent = os.path.basename(src_path)
217+
root_strip = src_path.replace(parent, "")
218+
two_depth_parent = os.path.basename(Path(src_path).parents[0])
217219
root_dir = os.path.join(two_depth_parent, parent)
218220
except Exception:
219221
root_dir = ""
@@ -224,6 +226,7 @@ def create_scancodejson(final_report, output_extension, ui_mode_report, src_path
224226
output_extension, '')
225227
if src_path:
226228
for root, dirs, files in os.walk(src_path):
229+
root = root.replace(root_strip, "")
227230
for file in files:
228231
item_path = os.path.join(root, file)
229232
item_path = item_path.replace(parent + os.path.sep, '', 1)

0 commit comments

Comments
 (0)