mirror of
https://github.com/transmission/transmission
synced 2025-01-30 10:52:00 +00:00
fix: assertion failed leftUntilDone <= sizeWhenDone (#4879)
This commit is contained in:
parent
f551b4adbf
commit
a982c96518
2 changed files with 21 additions and 4 deletions
|
@ -156,13 +156,28 @@ void tr_completion::addPiece(tr_piece_index_t piece)
|
|||
}
|
||||
}
|
||||
|
||||
void tr_completion::removeBlock(tr_block_index_t block)
|
||||
{
|
||||
if (!hasBlock(block))
|
||||
{
|
||||
return; // already didn't have it
|
||||
}
|
||||
|
||||
blocks_.unset(block);
|
||||
size_now_ -= block_info_->blockSize(block);
|
||||
|
||||
size_when_done_.reset();
|
||||
has_valid_.reset();
|
||||
}
|
||||
|
||||
void tr_completion::removePiece(tr_piece_index_t piece)
|
||||
{
|
||||
auto const [begin, end] = block_info_->blockSpanForPiece(piece);
|
||||
size_now_ -= countHasBytesInPiece(piece);
|
||||
size_when_done_.reset();
|
||||
has_valid_.reset();
|
||||
blocks_.unsetSpan(begin, end);
|
||||
|
||||
for (auto block = begin; block < end; ++block)
|
||||
{
|
||||
removeBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t tr_completion::countHasBytesInSpan(tr_byte_span_t span) const
|
||||
|
|
|
@ -172,6 +172,8 @@ private:
|
|||
return countHasBytesInSpan(block_info_->byteSpanForPiece(piece));
|
||||
}
|
||||
|
||||
void removeBlock(tr_block_index_t block);
|
||||
|
||||
torrent_view const* tor_;
|
||||
tr_block_info const* block_info_;
|
||||
|
||||
|
|
Loading…
Reference in a new issue