Changeset 10479


Ignore:
Timestamp:
Apr 14, 2010, 12:34:31 AM (12 years ago)
Author:
charles
Message:

(trunk libT) in seedRatio, handle the case where a file is downloaded more than once

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r10477 r10479  
    289289 * it applies if the torrent's a seed AND it has a seed ratio set */
    290290static tr_bool
    291 tr_torrentGetSeedRatioBytes( tr_torrent * tor, uint64_t * setmeLeft, uint64_t * setmeGoal )
     291tr_torrentGetSeedRatioBytes( tr_torrent  * tor,
     292                             uint64_t    * setmeLeft,
     293                             uint64_t    * setmeGoal )
    292294{
    293295    double seedRatio;
     
    296298    if( tr_torrentGetSeedRatio( tor, &seedRatio ) )
    297299    {
    298         const uint64_t upEver = tor->uploadedCur + tor->uploadedPrev;
    299         const uint64_t goal = seedRatio * tr_cpSizeWhenDone ( &tor->completion );
    300         if( setmeLeft ) *setmeLeft = goal > upEver ? goal - upEver : 0;
     300        const uint64_t u = tor->uploadedCur + tor->uploadedPrev;
     301        const uint64_t d = tor->downloadedCur + tor->downloadedPrev;
     302        const uint64_t baseline = d ? d : tr_cpSizeWhenDone( &tor->completion );
     303        const uint64_t goal = baseline * seedRatio;
     304        if( setmeLeft ) *setmeLeft = goal > u ? goal - u : 0;
    301305        if( setmeGoal ) *setmeGoal = goal;
    302306        seedRatioApplies = tr_torrentIsSeed( tor );
Note: See TracChangeset for help on using the changeset viewer.