From 89b3c5fc0a7395fb0b1b6b9a489945f58de5b7a2 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Sat, 15 Dec 2012 03:47:11 +0000 Subject: [PATCH] when a peer sends us a block and we count it in tr_cpBlockAdd(), don't invalidate cp.sizeWhenDone unless sizeWhenDone wasn't already including that new block. --- libtransmission/completion.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libtransmission/completion.c b/libtransmission/completion.c index 801fc595d..880ba4f79 100644 --- a/libtransmission/completion.c +++ b/libtransmission/completion.c @@ -102,11 +102,13 @@ tr_cpBlockAdd (tr_completion * cp, tr_block_index_t block) if (!tr_cpBlockIsComplete (cp, block)) { + const tr_piece_index_t piece = tr_torBlockPiece (cp->tor, block); + tr_bitfieldAdd (&cp->blockBitfield, block); cp->sizeNow += tr_torBlockCountBytes (tor, block); cp->haveValidIsDirty = true; - cp->sizeWhenDoneIsDirty = true; + cp->sizeWhenDoneIsDirty |= tor->info.pieces[piece].dnd; } } -- 2.40.0