mirror of
https://github.com/transmission/transmission
synced 2025-01-30 19:03:04 +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)
|
void tr_completion::removePiece(tr_piece_index_t piece)
|
||||||
{
|
{
|
||||||
auto const [begin, end] = block_info_->blockSpanForPiece(piece);
|
auto const [begin, end] = block_info_->blockSpanForPiece(piece);
|
||||||
size_now_ -= countHasBytesInPiece(piece);
|
|
||||||
size_when_done_.reset();
|
for (auto block = begin; block < end; ++block)
|
||||||
has_valid_.reset();
|
{
|
||||||
blocks_.unsetSpan(begin, end);
|
removeBlock(block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t tr_completion::countHasBytesInSpan(tr_byte_span_t span) const
|
uint64_t tr_completion::countHasBytesInSpan(tr_byte_span_t span) const
|
||||||
|
|
|
@ -172,6 +172,8 @@ private:
|
||||||
return countHasBytesInSpan(block_info_->byteSpanForPiece(piece));
|
return countHasBytesInSpan(block_info_->byteSpanForPiece(piece));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeBlock(tr_block_index_t block);
|
||||||
|
|
||||||
torrent_view const* tor_;
|
torrent_view const* tor_;
|
||||||
tr_block_info const* block_info_;
|
tr_block_info const* block_info_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue