Skip to content

Commit 0acfc81

Browse files
committed
Update windows filename
1 parent 0d0709b commit 0acfc81

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/scanoss/scanner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,9 @@ def __finish_scan_threaded(self, file_map: Optional[Dict[Any, Any]] = None) -> b
545545

546546
def _merge_scan_results(
547547
self,
548-
scan_responses: list | None,
549-
dep_responses: dict | None,
550-
file_map: dict | None,
548+
scan_responses: Optional[List],
549+
dep_responses: Optional[Dict[str,Any]],
550+
file_map: Optional[Dict[str, Any]],
551551
) -> Dict[str, Any]:
552552
"""Merge scan and dependency responses into a single dictionary"""
553553
results: Dict[str, Any] = {}

src/scanoss/winnowing.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -308,18 +308,15 @@ def wfp_for_contents(self, file: str, bin_file: bool, contents: bytes) -> str:
308308
return ''
309309
# Print file line
310310
content_length = len(contents)
311-
wfp_filename = repr(file).strip("'") # return a utf-8 compatible version of the filename
312-
if (
313-
self.obfuscate
314-
): # hide the real size of the file and its name, but keep the suffix
315-
wfp_filename = f'{self.ob_count}{pathlib.Path(file).suffix}'
316-
if platform.system() == "Windows":
317-
wfp_filename = wfp_filename.replace("\\", "/")
318-
file = file.replace("\\", "/")
311+
original_filename = file
312+
313+
if platform.system() == 'Windows':
314+
original_filename = file.replace('\\', '/')
315+
wfp_filename = repr(original_filename).strip("'") # return a utf-8 compatible version of the filename
316+
if self.obfuscate: # hide the real size of the file and its name, but keep the suffix
317+
wfp_filename = f'{self.ob_count}{pathlib.Path(original_filename).suffix}'
319318
self.ob_count = self.ob_count + 1
320-
self.file_map[wfp_filename] = (
321-
file # Save the file name map for later (reverse lookup)
322-
)
319+
self.file_map[wfp_filename] = original_filename # Save the file name map for later (reverse lookup)
323320

324321
wfp = 'file={0},{1},{2}\n'.format(file_md5, content_length, wfp_filename)
325322
# We don't process snippets for binaries, or other uninteresting files, or if we're requested to skip

0 commit comments

Comments
 (0)