mirror of
https://github.com/transmission/transmission
synced 2024-12-23 08:13:27 +00:00
fix a couple of related file priority bugs.
This commit is contained in:
parent
473907d891
commit
f8bc11e094
2 changed files with 18 additions and 13 deletions
|
@ -590,6 +590,14 @@ compareRefillPiece (const void * aIn, const void * bIn)
|
|||
const struct tr_refill_piece * a = aIn;
|
||||
const struct tr_refill_piece * b = bIn;
|
||||
|
||||
/* if one piece has a higher priority, it goes first */
|
||||
if (a->priority != b->priority)
|
||||
return a->priority > b->priority ? -1 : 1;
|
||||
|
||||
/* try to fill partial pieces */
|
||||
if( a->percentDone != b->percentDone )
|
||||
return a->percentDone > b->percentDone ? -1 : 1;
|
||||
|
||||
/* if one *might be* fastallowed to us, get it first...
|
||||
* I'm putting it on top so we prioritize those pieces at
|
||||
* startup, then we'll have them, and we'll be denied access
|
||||
|
@ -597,17 +605,9 @@ compareRefillPiece (const void * aIn, const void * bIn)
|
|||
if (a->fastAllowed != b->fastAllowed)
|
||||
return a->fastAllowed < b->fastAllowed ? -1 : 1;
|
||||
|
||||
/* if one piece has a higher priority, it goes first */
|
||||
if (a->priority != b->priority)
|
||||
return a->priority > b->priority ? -1 : 1;
|
||||
|
||||
/* otherwise if one was suggested to us, get it */
|
||||
if (a->suggested != b->suggested)
|
||||
return a->suggested < b->suggested ? -1 : 1;
|
||||
|
||||
/* try to fill partial pieces */
|
||||
if( a->percentDone != b->percentDone )
|
||||
return a->percentDone > b->percentDone ? -1 : 1;
|
||||
|
||||
/* otherwise if one has fewer peers, it goes first */
|
||||
if (a->peerCount != b->peerCount)
|
||||
|
|
|
@ -218,15 +218,20 @@ calculatePiecePriority ( const tr_torrent * tor,
|
|||
int piece )
|
||||
{
|
||||
int i;
|
||||
tr_priority_t priority = TR_PRI_NORMAL;
|
||||
tr_priority_t priority = TR_PRI_LOW;
|
||||
|
||||
/* the piece's priority is the max of the priorities
|
||||
* of all the files in that piece */
|
||||
for( i=0; i<tor->info.fileCount; ++i )
|
||||
{
|
||||
const tr_file * file = &tor->info.files[i];
|
||||
if ( file->firstPiece <= piece
|
||||
&& file->lastPiece >= piece
|
||||
&& file->priority > priority)
|
||||
priority = file->priority;
|
||||
|
||||
if( piece < file->firstPiece )
|
||||
continue;
|
||||
if( piece > file->lastPiece )
|
||||
break;
|
||||
|
||||
priority = MAX( priority, file->priority );
|
||||
|
||||
/* when dealing with multimedia files, getting the first and
|
||||
last pieces can sometimes allow you to preview it a bit
|
||||
|
|
Loading…
Reference in a new issue