From 39a09f27048ca8566e65e9064e37a523972d2433 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Wed, 19 Aug 2009 02:14:29 +0000 Subject: [PATCH] Fix piece size calculation --- deluge/maketorrent.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/deluge/maketorrent.py b/deluge/maketorrent.py index 1ca3d9da6..304c0aeec 100644 --- a/deluge/maketorrent.py +++ b/deluge/maketorrent.py @@ -127,11 +127,9 @@ class TorrentMetadata(object): piece_size = piece_size * 1024 else: # We need to calculate a piece size - psize = 16384 - while (datasize / psize) > 1024 and psize < 8192 * 1024: - psize *= 2 - - piece_size = psize / 1024 + piece_size = 16384 + while (datasize / piece_size) > 1024 and piece_size < (8192 * 1024): + piece_size *= 2 # Calculate the number of pieces we will require for the data num_pieces = datasize / piece_size