Fix piece size calculation

This commit is contained in:
Andrew Resch 2009-08-19 02:14:29 +00:00
parent 4ca5f9a371
commit 39a09f2704
1 changed files with 3 additions and 5 deletions

View File

@ -127,11 +127,9 @@ class TorrentMetadata(object):
piece_size = piece_size * 1024 piece_size = piece_size * 1024
else: else:
# We need to calculate a piece size # We need to calculate a piece size
psize = 16384 piece_size = 16384
while (datasize / psize) > 1024 and psize < 8192 * 1024: while (datasize / piece_size) > 1024 and piece_size < (8192 * 1024):
psize *= 2 piece_size *= 2
piece_size = psize / 1024
# Calculate the number of pieces we will require for the data # Calculate the number of pieces we will require for the data
num_pieces = datasize / piece_size num_pieces = datasize / piece_size