Skip to content

Commit 7a880ee

Browse files
committed
feat: align with go client again
1 parent 19b9c1e commit 7a880ee

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/scanoss/file_filters.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@
5858
'wheels',
5959
'htmlcov',
6060
'__pypackages__',
61-
# 'example',
62-
# 'examples',
63-
# 'docs',
64-
# 'tests',
65-
# 'doc',
66-
# 'test',
61+
'example',
62+
'examples',
63+
'docs',
64+
'tests',
65+
'doc',
66+
'test',
6767
}
6868

6969

src/scanoss/scanners/folder_hasher.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
MINIMUM_FILE_COUNT = 8
1717
MINIMUM_CONCATENATED_NAME_LENGTH = 32
18+
MINIMUM_FILE_NAME_LENGTH = 32
1819

1920

2021
class DirectoryNode:
@@ -137,7 +138,9 @@ def _build_root_node(self, path: str) -> DirectoryNode:
137138
root = Path(path).resolve()
138139
root_node = DirectoryNode(str(root))
139140

140-
all_files = [f for f in root.rglob('*') if f.is_file()]
141+
all_files = [
142+
f for f in root.rglob('*') if f.is_file() and len(f.name.encode('utf-8')) < MINIMUM_FILE_NAME_LENGTH
143+
]
141144
filtered_files = self.file_filters.get_filtered_files_from_files(all_files, str(root))
142145

143146
# Sort the files by name to ensure the hash is the same for the same folder
@@ -237,7 +240,7 @@ def _hash_calc(self, node: DirectoryNode) -> dict:
237240
selected_names.sort()
238241
concatenated_names = ''.join(selected_names)
239242

240-
if len(concatenated_names) < MINIMUM_CONCATENATED_NAME_LENGTH:
243+
if len(concatenated_names.encode('utf-8')) < MINIMUM_CONCATENATED_NAME_LENGTH:
241244
return {
242245
'name_hash': None,
243246
'content_hash': None,

0 commit comments

Comments
 (0)