Skip to content

Commit

Permalink
ANT piece size gap
Browse files Browse the repository at this point in the history
  • Loading branch information
Audionut committed Oct 25, 2024
1 parent ddfaa9f commit caacf5a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -2503,11 +2503,21 @@ def calculate_piece_size(cls, total_size, min_size, max_size, files):

# Adjust the piece size to fit within the constraints
while not (1000 <= num_pieces <= 2000 and torrent_file_size <= 102400): # 100 KiB .torrent size limit
if num_pieces < 1000:
if num_pieces < 1000 and torrent_file_size >= 102400:
piece_size *= 2
if piece_size > our_max_size:
piece_size = our_max_size
break
elif num_pieces < 1000:
piece_size //= 2
if piece_size < our_min_size:
piece_size = our_min_size
break
elif piece_size > 18000000 and torrent_file_size >= 102400:
piece_size *= 2
if piece_size > our_max_size:
piece_size = our_max_size
break
elif torrent_file_size > 61440: # Break if .torrent size exceeds 60 KiB
break
elif num_pieces > 2000:
Expand Down

0 comments on commit caacf5a

Please sign in to comment.