Skip to content

Commit

Permalink
Break with lesser pieces, not more
Browse files Browse the repository at this point in the history
Only print the size warning if we settled there.
  • Loading branch information
Audionut committed Oct 12, 2024
1 parent 7f5e7da commit 69911e5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -2470,18 +2470,18 @@ def calculate_piece_size(cls, total_size, min_size, max_size, files):
if piece_size < our_min_size:
piece_size = our_min_size
break
elif torrent_file_size > 92160: # Break if .torrent size exceeds 90 KiB
break
elif num_pieces > 2000:
piece_size *= 2
if piece_size > our_max_size:
piece_size = our_max_size
break
elif torrent_file_size > 92160: # Break if .torrent size exceeds 90 KiB
break
elif torrent_file_size > 102400:
cli_ui.warning('WARNING: .torrent size will exceed 100 KiB!')
piece_size *= 2
if piece_size > our_max_size:
piece_size = our_max_size
cli_ui.warning('WARNING: .torrent size will exceed 100 KiB!')
break
num_pieces = math.ceil(total_size / piece_size)
torrent_file_size = 20 + (num_pieces * 20) + cls._calculate_pathname_bytes(files)
Expand Down

0 comments on commit 69911e5

Please sign in to comment.