1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-03 13:35:36 +00:00

move the percent to the stop ratio into libtransmission

This commit is contained in:
Mitchell Livingston 2009-03-01 23:48:04 +00:00
parent 7254f0d79a
commit 2dabe5ce34
3 changed files with 17 additions and 11 deletions

View file

@ -804,6 +804,7 @@ tr_torrentStat( tr_torrent * tor )
int usableSeeds = 0;
uint64_t now;
double downloadedForRatio, seedRatio;
tr_bool checkSeedRatio;
if( !tor )
return NULL;
@ -861,7 +862,6 @@ tr_torrentStat( tr_torrent * tor )
(double) tor->info.pieceCount )
: 0.0;
s->activityDate = tor->activityDate;
s->addedDate = tor->addedDate;
s->doneDate = tor->doneDate;
@ -896,6 +896,8 @@ tr_torrentStat( tr_torrent * tor )
downloadedForRatio = s->downloadedEver ? s->downloadedEver : s->haveValid;
s->ratio = tr_getRatio( s->uploadedEver, downloadedForRatio );
checkSeedRatio = tr_torrentGetSeedRatio( tor, &seedRatio );
switch( s->activity )
{
case TR_STATUS_DOWNLOAD:
@ -908,7 +910,7 @@ tr_torrentStat( tr_torrent * tor )
break;
case TR_STATUS_SEED:
if( tr_torrentGetSeedRatio( tor, &seedRatio ) )
if( checkSeedRatio )
{
if( s->pieceUploadSpeed < 0.1 )
s->eta = TR_ETA_UNKNOWN;
@ -924,6 +926,13 @@ tr_torrentStat( tr_torrent * tor )
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 );
return s;
@ -2148,7 +2157,6 @@ tr_torrentCheckSeedRatio( tr_torrent * tor )
/* maybe notify the client */
if( tor->ratio_limit_hit_func != NULL )
tor->ratio_limit_hit_func( tor, tor->ratio_limit_hit_func_user_data );
}
}
}

View file

@ -1315,6 +1315,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

@ -387,16 +387,9 @@ int trashDataFile(const char * filename)
return tr_torrentGetSeedRatio(fHandle, NULL);
}
#warning move to libtransmission
- (CGFloat) progressStopRatio
{
double stopRatio, ratio;
if (!tr_torrentGetSeedRatio(fHandle, &stopRatio) || (ratio = [self ratio]) >= stopRatio)
return 1.0;
else if (stopRatio > 0.0)
return ratio / stopRatio;
else
return 0.0;
return fStat->percentRatio;
}
- (tr_speedlimit) speedMode: (BOOL) upload