mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
Fix creating torrent with file size less than smallest piece size
This commit is contained in:
parent
b83ef477e4
commit
ecb80ea689
1 changed files with 9 additions and 2 deletions
|
@ -147,7 +147,10 @@ def makeinfo(path, piece_length, progress, name = None,
|
||||||
totalhashed = 0
|
totalhashed = 0
|
||||||
for p, f in subs:
|
for p, f in subs:
|
||||||
totalsize += os.path.getsize(f)
|
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:
|
for p, f in subs:
|
||||||
pos = 0
|
pos = 0
|
||||||
|
@ -188,7 +191,11 @@ def makeinfo(path, piece_length, progress, name = None,
|
||||||
'private': private}
|
'private': private}
|
||||||
else:
|
else:
|
||||||
size = os.path.getsize(path)
|
size = os.path.getsize(path)
|
||||||
num_pieces = size / piece_length
|
if size >= piece_length:
|
||||||
|
num_pieces = size / piece_length
|
||||||
|
else:
|
||||||
|
num_pieces = 1
|
||||||
|
|
||||||
pieces = []
|
pieces = []
|
||||||
p = 0
|
p = 0
|
||||||
h = file(path, 'rb')
|
h = file(path, 'rb')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue