From a0ab29bb8db8d44345e5a94827852b50a42b6c80 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Fri, 5 May 2017 03:33:20 +0200 Subject: [PATCH] Made sure that parts are below the part_length even after adding the checksum. --- paperize/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/paperize/main.py b/paperize/main.py index 812328a..195986c 100755 --- a/paperize/main.py +++ b/paperize/main.py @@ -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