Skip to content

Commit

Permalink
[FIX] Fix ZeroDivisionError for files < processes case
Browse files Browse the repository at this point in the history
  • Loading branch information
KeyWeeUsr committed Jul 1, 2019
1 parent 888b058 commit 477269d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bear/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ def find_duplicates(folders: list, hasher: Hasher, processes: int = 1) -> dict:
files = [file for file_list in found for file in file_list]
files_len = len(files)
chunk_size = int(files_len // processes)
if chunk_size == 0:
# watch out for zero division
LOG.critical((
'Zero chunk size for files: %d, processes: %d! '
'Using 1 as default.'
), files_len, processes)
chunk_size = 1

# hash chunks of flat list files
with Pool(processes=processes) as pool:
Expand Down

0 comments on commit 477269d

Please sign in to comment.