From 87d58cd0e16cbbdd43c62288318127913eab386e Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Wed, 5 Sep 2007 13:25:46 +0000 Subject: [PATCH] firstlast fix by andar --- src/deluge_core.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/deluge_core.cpp b/src/deluge_core.cpp index af12e08ab..70535c53c 100644 --- a/src/deluge_core.cpp +++ b/src/deluge_core.cpp @@ -1828,7 +1828,9 @@ static PyObject *torrent_prioritize_first_last_pieces(PyObject *self, } int start_piece = tor_info.map_file(i, 0, 0).piece; - int end_piece = tor_info.map_file(i, file.size, 0).piece -1; + int end_piece = tor_info.map_file(i, file.size, 0).piece; + if (end_piece == num_pieces) + end_piece -= 1; // Set prio_size to 1% of the file size size_type prio_size = file.size / 100; int prio_pieces = tor_info.map_file(i, prio_size, 0).piece -