Ignore:
Timestamp:
Jun 22, 2007, 12:44:26 AM (15 years ago)
Author:
charles
Message:

Maybe fix the bug of progress-for-done not including non-checked files even if they're finished

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/completion.c

    r2149 r2182  
    378378tr_cpPercentComplete ( const tr_completion_t * cp )
    379379{
    380     int i;
    381     uint64_t have=0;
    382     const tr_torrent_t * tor;
    383 
    384     assert( cp != NULL );
    385     assert( cp->tor != NULL );
    386 
    387     tor = cp->tor;
    388     for( i=0; i<tor->info.pieceCount; ++i )
    389         have += cp->completeBlocks[ i ];
    390 
    391     return tor->blockCount ? (float)have / (float)tor->blockCount : 0.0f;
     380    const uint64_t tilComplete = tr_cpLeftUntilComplete( cp );
     381    const uint64_t total = cp->tor->info.totalSize;
     382    return 1.0 - (double)tilComplete / total;
    392383}
    393384
     
    395386tr_cpPercentDone( const tr_completion_t * cp )
    396387{
    397     int i;
    398     uint64_t have=0, total=0;
    399     const tr_torrent_t * tor;
    400 
    401     assert( cp != NULL );
    402     assert( cp->tor != NULL );
    403 
    404     tor = cp->tor;
    405 
    406     for( i=0; i<tor->info.pieceCount; ++i ) {
    407         if( tor->info.pieces[i].priority != TR_PRI_DND) {
    408             total += tr_cpCountBlocks( cp, i );
    409             have += cp->completeBlocks[ i ];
    410         }
    411     }
    412 
    413     return !total ? 0.0f : (float)have / (float)total;
     388    const uint64_t tilDone = tr_cpLeftUntilDone( cp );
     389    const uint64_t total = cp->tor->info.totalSize;
     390    return 1.0 - (double)tilDone / total;
    414391}
    415392
Note: See TracChangeset for help on using the changeset viewer.