Changeset 1767


Ignore:
Timestamp:
Apr 20, 2007, 11:51:15 PM (15 years ago)
Author:
livings124
Message:

expand the last commit a bit so that ratio is calculated with the actual downloaded amount if amount downloaded in T is 0. This should eliminate ever showing infinity for ratio.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r1766 r1767  
    462462    if( s->downloaded == 0 )
    463463    {
    464         //if seeding without ever downloading, calculate ratio from total size
    465         if( s->progress >= 1.0 )
    466         {
    467             s->ratio = (float)s->uploaded / (float)inf->totalSize;
     464        //if some is downloaded without a downloaded value, calculate ratio from total size
     465        if( s->progress > 0.0 )
     466        {
     467            s->ratio = (float)s->uploaded / ((float)inf->totalSize * s->progress);
    468468        }
    469469        else
    470470        {
    471             s->ratio = s->uploaded == 0 ? TR_RATIO_NA : TR_RATIO_INF;
     471            s->ratio = TR_RATIO_NA;
    472472        }
    473473    }
  • trunk/libtransmission/transmission.h

    r1763 r1767  
    449449
    450450#define TR_RATIO_NA  -1
    451 #define TR_RATIO_INF -2
    452451    float               ratio;
    453452};
  • trunk/macosx/StringAdditions.m

    r1645 r1767  
    106106    if (ratio == TR_RATIO_NA)
    107107        return NSLocalizedString(@"N/A", "No Ratio");
    108     else if (ratio == TR_RATIO_INF)
    109         return [NSString stringWithUTF8String: "\xE2\x88\x9E"];
    110108    else if (ratio < 0)
    111109        return NSLocalizedString(@"error", "Ratio invalid");
     110    else;
    112111   
    113112    if (ratio < 10.0)
  • trunk/macosx/Torrent.m

    r1765 r1767  
    290290   
    291291    //check to stop for ratio
    292     float stopRatio, ratio;
     292    float stopRatio;
    293293    if ([self isSeeding] && (stopRatio = [self actualStopRatio]) != INVALID
    294                         && ((ratio = [self ratio]) >= stopRatio || ratio == TR_RATIO_INF))
     294                        && [self ratio] >= stopRatio)
    295295    {
    296296        [self stopTransfer];
     
    12571257- (NSNumber *) ratioSortKey
    12581258{
    1259     float ratio = [self ratio];
    1260     if (ratio == TR_RATIO_INF)
    1261         return [NSNumber numberWithInt: 999999999]; //this should hopefully be big enough
    1262     else
    1263         return [NSNumber numberWithFloat: [self ratio]];
     1259    return [NSNumber numberWithFloat: [self ratio]];
    12641260}
    12651261
Note: See TracChangeset for help on using the changeset viewer.