From ecb80ea68971af5f9e5d82749a86e1659e92bd3c Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Thu, 23 Oct 2008 13:22:40 +0000 Subject: [PATCH] Fix creating torrent with file size less than smallest piece size --- deluge/metafile.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/deluge/metafile.py b/deluge/metafile.py index 2b5620a58..120a40a99 100644 --- a/deluge/metafile.py +++ b/deluge/metafile.py @@ -147,7 +147,10 @@ def makeinfo(path, piece_length, progress, name = None, totalhashed = 0 for p, f in subs: totalsize += os.path.getsize(f) - num_pieces = totalsize / piece_length + if totalsize >= piece_length: + num_pieces = totalsize / piece_length + else: + num_pieces = 1 for p, f in subs: pos = 0 @@ -188,7 +191,11 @@ def makeinfo(path, piece_length, progress, name = None, 'private': private} else: size = os.path.getsize(path) - num_pieces = size / piece_length + if size >= piece_length: + num_pieces = size / piece_length + else: + num_pieces = 1 + pieces = [] p = 0 h = file(path, 'rb')