From 253660d628d1fb182a05e9074eab510318b43ecf Mon Sep 17 00:00:00 2001 From: jmbardallo Date: Thu, 17 Sep 2026 12:21:58 +0200 Subject: [PATCH] fix: adjust seek offset for small files in createTorrentSum --- bin/createTorrentSum.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/createTorrentSum.py b/bin/createTorrentSum.py index 766f53e..e75dffa 100644 --- a/bin/createTorrentSum.py +++ b/bin/createTorrentSum.py @@ -96,8 +96,13 @@ def get_md5_sum(file_path, megabytes=1): Se utiliza para crear el archivo ".sum" (para transferencias Unicast y Multicast). """ hash_md5 = hashlib.md5() + file_size = os.path.getsize(file_path) + seek_offset = -megabytes * 1024 * 1024 + if file_size < (-seek_offset): + seek_offset = -file_size + with open(file_path, "rb") as f: - f.seek(-megabytes * 1024 * 1024, os.SEEK_END) + f.seek(seek_offset, os.SEEK_END) data = f.read(megabytes * 1024 * 1024) hash_md5.update(data) return hash_md5.hexdigest()