Made sure that parts are below the part_length even after adding the checksum.

This commit is contained in:
Faerbit 2017-05-05 03:33:20 +02:00
parent 7e0734b0cc
commit a0ab29bb8d

View File

@ -199,7 +199,12 @@ def prepare_data(data, no_parts, part_length, file_name, hashsum):
ret.append(part_header + part + PART_TRAILER)
data = fill(data, 80)[length:]
i += 1
ret[-1] = ret[-1] + CHECKSUM.format(sum=hashsum)
checksum = CHECKSUM.format(sum=hashsum)
if (len(ret[-1]) + len(checksum) < part_length):
ret[-1] = ret[-1] + checksum
else:
ret.append(PART_HEADER.format(part=len(ret)+1, parts=no_parts)[:-1]
+ PART_TRAILER + checksum)
return ret