on second thought, the other UI's might want this value sooner or later, and it's cheaper to calculate it in the stat function

This commit is contained in:
Mitchell Livingston 2009-10-25 18:49:20 +00:00
parent a5e0b6e5b2
commit 130c9af1d1
3 changed files with 13 additions and 7 deletions

View File

@ -1023,6 +1023,13 @@ tr_torrentStat( tr_torrent * tor )
s->eta = TR_ETA_NOT_AVAIL;
break;
}
if( !checkSeedRatio || s->ratio >= seedRatio || s->ratio == TR_RATIO_INF )
s->percentRatio = 1.0;
else if( s->ratio == TR_RATIO_NA )
s->percentRatio = 0.0;
else
s->percentRatio = s->ratio / seedRatio;
tr_torrentUnlock( tor );

View File

@ -1628,6 +1628,11 @@ typedef struct tr_stat
@see tr_stat.leftUntilDone */
float percentDone;
/** The percentage of the actual ratio to the seed ratio. This will be
equal to 1 if the ratio is reached or the torrent is set to seed forever.
Range is [0..1] */
float percentRatio;
/** Speed all data being sent for this torrent. (KiB/s)
This includes piece data, protocol messages, and TCP overhead */
double rawUploadSpeed;

View File

@ -343,13 +343,7 @@ int trashDataFile(const char * filename)
- (CGFloat) progressStopRatio
{
double seedRatio;
if (!tr_torrentGetSeedRatio(fHandle, seedRatio) || [self ratio] >= seedRatio || [self ratio] == TR_RATIO_INF)
return 1.0;
else if ([self ratio] == TR_RATIO_NA)
return 0.0;
else
return [self ratio] / seedRatio;
return fStat->percentRatio;
}
- (BOOL) usesSpeedLimit: (BOOL) upload