mirror of
https://github.com/transmission/transmission.git
synced 2026-05-08 09:39:08 +01:00
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.
This commit is contained in:
@@ -461,14 +461,14 @@ tr_stat_t * tr_torrentStat( tr_torrent_t * tor )
|
||||
|
||||
if( s->downloaded == 0 )
|
||||
{
|
||||
//if seeding without ever downloading, calculate ratio from total size
|
||||
if( s->progress >= 1.0 )
|
||||
//if some is downloaded without a downloaded value, calculate ratio from total size
|
||||
if( s->progress > 0.0 )
|
||||
{
|
||||
s->ratio = (float)s->uploaded / (float)inf->totalSize;
|
||||
s->ratio = (float)s->uploaded / ((float)inf->totalSize * s->progress);
|
||||
}
|
||||
else
|
||||
{
|
||||
s->ratio = s->uploaded == 0 ? TR_RATIO_NA : TR_RATIO_INF;
|
||||
s->ratio = TR_RATIO_NA;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -448,7 +448,6 @@ struct tr_stat_s
|
||||
float swarmspeed;
|
||||
|
||||
#define TR_RATIO_NA -1
|
||||
#define TR_RATIO_INF -2
|
||||
float ratio;
|
||||
};
|
||||
|
||||
|
||||
@@ -105,10 +105,9 @@
|
||||
{
|
||||
if (ratio == TR_RATIO_NA)
|
||||
return NSLocalizedString(@"N/A", "No Ratio");
|
||||
else if (ratio == TR_RATIO_INF)
|
||||
return [NSString stringWithUTF8String: "\xE2\x88\x9E"];
|
||||
else if (ratio < 0)
|
||||
return NSLocalizedString(@"error", "Ratio invalid");
|
||||
else;
|
||||
|
||||
if (ratio < 10.0)
|
||||
return [NSString stringWithFormat: @"%.2f", ratio];
|
||||
|
||||
+3
-7
@@ -289,9 +289,9 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||
}
|
||||
|
||||
//check to stop for ratio
|
||||
float stopRatio, ratio;
|
||||
float stopRatio;
|
||||
if ([self isSeeding] && (stopRatio = [self actualStopRatio]) != INVALID
|
||||
&& ((ratio = [self ratio]) >= stopRatio || ratio == TR_RATIO_INF))
|
||||
&& [self ratio] >= stopRatio)
|
||||
{
|
||||
[self stopTransfer];
|
||||
fStat = tr_torrentStat(fHandle);
|
||||
@@ -1256,11 +1256,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||
|
||||
- (NSNumber *) ratioSortKey
|
||||
{
|
||||
float ratio = [self ratio];
|
||||
if (ratio == TR_RATIO_INF)
|
||||
return [NSNumber numberWithInt: 999999999]; //this should hopefully be big enough
|
||||
else
|
||||
return [NSNumber numberWithFloat: [self ratio]];
|
||||
return [NSNumber numberWithFloat: [self ratio]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user