Ignore:
Timestamp:
Apr 26, 2008, 2:52:05 PM (14 years ago)
Author:
charles
Message:

fix an assertion error: completion.c:113: failed assertion `ccp->sizeWhenDoneLazy >= ccp->sizeNow'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/completion.c

    r5682 r5706  
    9898    {
    9999        tr_completion * cp = (tr_completion *) ccp; /* mutable */
    100         const tr_info * info = &cp->tor->info;
     100        const tr_torrent * tor = cp->tor;
     101        const tr_info * info = &tor->info;
    101102        tr_piece_index_t i;
    102103        uint64_t size = 0;
    103104
    104105        for( i=0; i<info->pieceCount; ++i )
    105             if( !info->pieces[i].dnd || tr_cpPieceIsComplete( cp, i ) )
    106                 size += tr_torPieceCountBytes( cp->tor, i );
     106        {
     107            if( !info->pieces[i].dnd ) {
     108                // we want the piece...
     109                size += tr_torPieceCountBytes( tor, i );
     110            } else if( tr_cpPieceIsComplete( cp, i ) ) {
     111                // we have the piece...
     112                size += tr_torPieceCountBytes( tor, i );
     113            } else if( cp->completeBlocks[i] ) {
     114                // we have part of the piece...
     115                const tr_block_index_t b = tr_torPieceFirstBlock( tor, i );
     116                const tr_block_index_t e = b + tr_torPieceCountBlocks( tor, i );
     117                tr_block_index_t j;
     118                for( j=b; j<e; ++j )
     119                    if( tr_cpBlockIsComplete( cp, j ) )
     120                        size += tr_torBlockCountBytes( tor, j );
     121            }
     122        }
    107123
    108124        cp->sizeWhenDoneLazy = size;
Note: See TracChangeset for help on using the changeset viewer.