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:
parent
7254f0d79a
commit
2dabe5ce34
3 changed files with 17 additions and 11 deletions
|
@ -804,6 +804,7 @@ tr_torrentStat( tr_torrent * tor )
|
||||||
int usableSeeds = 0;
|
int usableSeeds = 0;
|
||||||
uint64_t now;
|
uint64_t now;
|
||||||
double downloadedForRatio, seedRatio;
|
double downloadedForRatio, seedRatio;
|
||||||
|
tr_bool checkSeedRatio;
|
||||||
|
|
||||||
if( !tor )
|
if( !tor )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -861,7 +862,6 @@ tr_torrentStat( tr_torrent * tor )
|
||||||
(double) tor->info.pieceCount )
|
(double) tor->info.pieceCount )
|
||||||
: 0.0;
|
: 0.0;
|
||||||
|
|
||||||
|
|
||||||
s->activityDate = tor->activityDate;
|
s->activityDate = tor->activityDate;
|
||||||
s->addedDate = tor->addedDate;
|
s->addedDate = tor->addedDate;
|
||||||
s->doneDate = tor->doneDate;
|
s->doneDate = tor->doneDate;
|
||||||
|
@ -896,6 +896,8 @@ tr_torrentStat( tr_torrent * tor )
|
||||||
downloadedForRatio = s->downloadedEver ? s->downloadedEver : s->haveValid;
|
downloadedForRatio = s->downloadedEver ? s->downloadedEver : s->haveValid;
|
||||||
s->ratio = tr_getRatio( s->uploadedEver, downloadedForRatio );
|
s->ratio = tr_getRatio( s->uploadedEver, downloadedForRatio );
|
||||||
|
|
||||||
|
checkSeedRatio = tr_torrentGetSeedRatio( tor, &seedRatio );
|
||||||
|
|
||||||
switch( s->activity )
|
switch( s->activity )
|
||||||
{
|
{
|
||||||
case TR_STATUS_DOWNLOAD:
|
case TR_STATUS_DOWNLOAD:
|
||||||
|
@ -908,7 +910,7 @@ tr_torrentStat( tr_torrent * tor )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TR_STATUS_SEED:
|
case TR_STATUS_SEED:
|
||||||
if( tr_torrentGetSeedRatio( tor, &seedRatio ) )
|
if( checkSeedRatio )
|
||||||
{
|
{
|
||||||
if( s->pieceUploadSpeed < 0.1 )
|
if( s->pieceUploadSpeed < 0.1 )
|
||||||
s->eta = TR_ETA_UNKNOWN;
|
s->eta = TR_ETA_UNKNOWN;
|
||||||
|
@ -924,6 +926,13 @@ tr_torrentStat( tr_torrent * tor )
|
||||||
break;
|
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 );
|
tr_torrentUnlock( tor );
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
@ -2148,7 +2157,6 @@ tr_torrentCheckSeedRatio( tr_torrent * tor )
|
||||||
/* maybe notify the client */
|
/* maybe notify the client */
|
||||||
if( tor->ratio_limit_hit_func != NULL )
|
if( tor->ratio_limit_hit_func != NULL )
|
||||||
tor->ratio_limit_hit_func( tor, tor->ratio_limit_hit_func_user_data );
|
tor->ratio_limit_hit_func( tor, tor->ratio_limit_hit_func_user_data );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1314,6 +1314,11 @@ typedef struct tr_stat
|
||||||
Range is [0..1]
|
Range is [0..1]
|
||||||
@see tr_stat.leftUntilDone */
|
@see tr_stat.leftUntilDone */
|
||||||
float percentDone;
|
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)
|
/** Speed all data being sent for this torrent. (KiB/s)
|
||||||
This includes piece data, protocol messages, and TCP overhead */
|
This includes piece data, protocol messages, and TCP overhead */
|
||||||
|
|
|
@ -387,16 +387,9 @@ int trashDataFile(const char * filename)
|
||||||
return tr_torrentGetSeedRatio(fHandle, NULL);
|
return tr_torrentGetSeedRatio(fHandle, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#warning move to libtransmission
|
|
||||||
- (CGFloat) progressStopRatio
|
- (CGFloat) progressStopRatio
|
||||||
{
|
{
|
||||||
double stopRatio, ratio;
|
return fStat->percentRatio;
|
||||||
if (!tr_torrentGetSeedRatio(fHandle, &stopRatio) || (ratio = [self ratio]) >= stopRatio)
|
|
||||||
return 1.0;
|
|
||||||
else if (stopRatio > 0.0)
|
|
||||||
return ratio / stopRatio;
|
|
||||||
else
|
|
||||||
return 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (tr_speedlimit) speedMode: (BOOL) upload
|
- (tr_speedlimit) speedMode: (BOOL) upload
|
||||||
|
|
Loading…
Reference in a new issue