#1379 lay some very early groundwork for "partial seeds" -- change tr_completion's enum to use the partial seed terminology

This commit is contained in:
Charles Kerr
2008-11-30 01:52:45 +00:00
parent e24b2b289b
commit c910993b68
6 changed files with 30 additions and 31 deletions
+1 -1
View File
@@ -166,7 +166,7 @@ completenessChangedCallback( tr_torrent * tor UNUSED,
tr_completeness completeness,
void * user_data )
{
if( completeness == TR_CP_COMPLETE )
if( completeness != TR_LEECH )
g_idle_add( notifyInMainThread, user_data );
}
+5 -6
View File
@@ -302,9 +302,9 @@ tr_cpLeftUntilComplete( const tr_completion * cp )
tr_completeness
tr_cpGetStatus( const tr_completion * cp )
{
if( cp->sizeNow == cp->tor->info.totalSize ) return TR_CP_COMPLETE;
if( cp->sizeNow == tr_cpSizeWhenDone( cp ) ) return TR_CP_DONE;
return TR_CP_INCOMPLETE;
if( cp->sizeNow == cp->tor->info.totalSize ) return TR_SEED;
if( cp->sizeNow == tr_cpSizeWhenDone( cp ) ) return TR_PARTIAL_SEED;
return TR_LEECH;
}
static uint64_t
@@ -354,8 +354,7 @@ tr_cpGetAmountDone( const tr_completion * cp,
int i;
const tr_torrent * tor = cp->tor;
const float interval = tor->info.pieceCount / (float)tabCount;
const int isComplete = tr_cpGetStatus ( tor->completion ) ==
TR_CP_COMPLETE;
const int isSeed = tr_cpGetStatus ( tor->completion ) == TR_SEED;
for( i = 0; i < tabCount; ++i )
{
@@ -363,7 +362,7 @@ tr_cpGetAmountDone( const tr_completion * cp,
if( tor == NULL )
tab[i] = 0.0f;
else if( isComplete || tr_cpPieceIsComplete( cp, piece ) )
else if( isSeed || tr_cpPieceIsComplete( cp, piece ) )
tab[i] = 1.0f;
else
tab[i] = (float)cp->completeBlocks[piece] /
+3 -4
View File
@@ -1540,7 +1540,7 @@ tr_peerMgrTorrentAvailability( const tr_peerMgr * manager,
const Torrent * t;
const tr_torrent * tor;
float interval;
int isComplete;
int isSeed;
int peerCount;
const tr_peer ** peers;
@@ -1549,8 +1549,7 @@ tr_peerMgrTorrentAvailability( const tr_peerMgr * manager,
t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
tor = t->tor;
interval = tor->info.pieceCount / (float)tabCount;
isComplete = tor
&& ( tr_cpGetStatus ( tor->completion ) == TR_CP_COMPLETE );
isSeed = tor && ( tr_cpGetStatus ( tor->completion ) == TR_SEED );
peers = (const tr_peer **) tr_ptrArrayPeek( t->peers, &peerCount );
memset( tab, 0, tabCount );
@@ -1559,7 +1558,7 @@ tr_peerMgrTorrentAvailability( const tr_peerMgr * manager,
{
const int piece = i * interval;
if( isComplete || tr_cpPieceIsComplete( tor->completion, piece ) )
if( isSeed || tr_cpPieceIsComplete( tor->completion, piece ) )
tab[i] = -1;
else if( peerCount )
{
+8 -8
View File
@@ -750,7 +750,7 @@ tr_torrentGetActivity( tr_torrent * tor )
return TR_STATUS_CHECK_WAIT;
if( !tor->isRunning )
return TR_STATUS_STOPPED;
if( tor->completeness == TR_CP_INCOMPLETE )
if( tor->completeness == TR_LEECH )
return TR_STATUS_DOWNLOAD;
return TR_STATUS_SEED;
@@ -1261,10 +1261,10 @@ getCompletionString( int type )
"Complete" means we've downloaded every file in the torrent.
"Done" means we're done downloading the files we wanted, but NOT all
that exist */
case TR_CP_DONE:
case TR_PARTIAL_SEED:
return _( "Done" );
case TR_CP_COMPLETE:
case TR_SEED:
return _( "Complete" );
default:
@@ -1277,9 +1277,9 @@ fireCompletenessChange( tr_torrent * tor,
tr_completeness status )
{
assert( tor );
assert( ( status == TR_CP_INCOMPLETE )
|| ( status == TR_CP_DONE )
|| ( status == TR_CP_COMPLETE ) );
assert( ( status == TR_LEECH )
|| ( status == TR_SEED )
|| ( status == TR_PARTIAL_SEED ) );
if( tor->completeness_func )
tor->completeness_func( tor, status, tor->completeness_func_user_data );
@@ -1324,7 +1324,7 @@ tr_torrentRecheckCompleteness( tr_torrent * tor )
tor->completeness = completeness;
fireCompletenessChange( tor, completeness );
if( recentChange && ( completeness == TR_CP_COMPLETE ) )
if( recentChange && ( completeness == TR_SEED ) )
{
tr_trackerCompleted( tor->tracker );
@@ -1340,7 +1340,7 @@ tr_torrentRecheckCompleteness( tr_torrent * tor )
int
tr_torrentIsSeed( const tr_torrent * tor )
{
return tor->completeness == TR_CP_COMPLETE || tor->completeness == TR_CP_DONE;
return tor->completeness == TR_SEED || tor->completeness == TR_PARTIAL_SEED;
}
/**
+10 -9
View File
@@ -995,9 +995,9 @@ void tr_torrentSetAnnounceList( tr_torrent * torrent,
typedef enum
{
TR_CP_INCOMPLETE, /* doesn't have all the desired pieces */
TR_CP_DONE, /* has all the desired pieces, but not all pieces */
TR_CP_COMPLETE /* has every piece */
TR_LEECH, /* doesn't have all the desired pieces */
TR_SEED, /* has the entire torrent */
TR_PARTIAL_SEED /* has the desired pieces, but not the entire torrent */
}
tr_completeness;
@@ -1008,8 +1008,8 @@ typedef void ( tr_torrent_completeness_func )( tr_torrent * torrent,
/**
* Register to be notified whenever a torrent's "completeness"
* changes. This will be called, for example, when a torrent
* finishes downloading and changes from TR_CP_INCOMPLETE to
* either TR_CP_COMPLETE or TR_CP_DONE.
* finishes downloading and changes from TR_LEECH to
* either TR_SEED or TR_PARTIAL_SEED.
*
* func is invoked FROM LIBTRANSMISSION'S THREAD!
* This means func must be fast (to avoid blocking peers),
@@ -1326,12 +1326,13 @@ typedef struct tr_stat
int timesCompleted;
/** Byte count of all the piece data we'll have downloaded when we're done,
whether or not we have it yet. [0...tr_info.totalSize] */
whether or not we have it yet. This may be less than tr_info.totalSize
if only some of the torrent's files are wanted.
[0...tr_info.totalSize] */
uint64_t sizeWhenDone;
/** Byte count of how much data is left to be downloaded until
we're done -- that is, until we've got all the pieces we wanted.
[0...tr_info.sizeWhenDone] */
/** Byte count of how much data is left to be downloaded until we've got
all the pieces that we want. [0...tr_info.sizeWhenDone] */
uint64_t leftUntilDone;
/** Byte count of all the piece data we want and don't have yet,
+3 -3
View File
@@ -1885,8 +1885,8 @@ void completenessChangeCallback(tr_torrent * torrent, tr_completeness status, vo
BOOL canMove;
switch ([status intValue])
{
case TR_CP_DONE:
case TR_CP_COMPLETE:
case TR_SEED:
case TR_PARTIAL_SEED:
canMove = YES;
//move file from incomplete folder to download folder
@@ -1919,7 +1919,7 @@ void completenessChangeCallback(tr_torrent * torrent, tr_completeness status, vo
[[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self];
break;
case TR_CP_INCOMPLETE:
case TR_LEECH:
//do not allow to be backed up by Time Machine
[self setTimeMachineExclude: YES forPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]];