Remove duplicate hash entries with a single path in get_duplicate_hashes method

This commit is contained in:
Will Miao
2025-06-11 17:33:13 +08:00
parent e81e96f0ab
commit e0d9880b32

View File

@@ -220,6 +220,15 @@ class ModelHashIndex:
def get_duplicate_hashes(self) -> Dict[str, List[str]]: def get_duplicate_hashes(self) -> Dict[str, List[str]]:
"""Get dictionary of duplicate hashes and their paths""" """Get dictionary of duplicate hashes and their paths"""
# Remove entries that have only one path
hashes_to_remove = []
for sha256, paths in self._duplicate_hashes.items():
if len(paths) <= 1:
hashes_to_remove.append(sha256)
for sha256 in hashes_to_remove:
del self._duplicate_hashes[sha256]
return self._duplicate_hashes return self._duplicate_hashes
def get_duplicate_filenames(self) -> Dict[str, List[str]]: def get_duplicate_filenames(self) -> Dict[str, List[str]]: