Changeset 4326


Ignore:
Timestamp:
Dec 25, 2007, 6:37:21 AM (14 years ago)
Author:
charles
Message:

fix another file priority bug.

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fastresume.c

    r4324 r4326  
    486486               default:  priority = TR_PRI_NORMAL; break;
    487487           }
    488            tor->info.files[i].priority = priority;
     488           tr_torrentInitFilePriority( tor, i, priority );
    489489        }
    490490
  • trunk/libtransmission/peer-mgr.c

    r4325 r4326  
    592592   
    593593    /* if one piece has a higher priority, it goes first */
    594     if (a->priority != b->priority)
     594    if( a->priority != b->priority )
    595595        return a->priority > b->priority ? -1 : 1;
    596596
  • trunk/libtransmission/torrent.c

    r4325 r4326  
    214214}
    215215
     216static int
     217pieceHasFile( int piece, const tr_file * file )
     218{
     219    return ( file->firstPiece <= piece ) && ( piece <= file->lastPiece );
     220}
     221
    216222static tr_priority_t
    217223calculatePiecePriority ( const tr_torrent * tor,
     
    219225{
    220226    int i;
    221     tr_priority_t priority = TR_PRI_LOW;
     227    int priority = TR_PRI_LOW;
    222228
    223229    /* the piece's priority is the max of the priorities
     
    227233        const tr_file * file = &tor->info.files[i];
    228234
    229         if( piece < file->firstPiece )
     235        if( !pieceHasFile( piece, file ) )
    230236            continue;
    231         if( piece > file->lastPiece )
    232             break;
    233237
    234238        priority = MAX( priority, file->priority );
     
    10581062**/
    10591063
    1060 static void
    1061 setFilePriority( tr_torrent   * tor,
    1062                  int            fileIndex,
    1063                  tr_priority_t  priority )
     1064void
     1065tr_torrentInitFilePriority( tr_torrent   * tor,
     1066                            int            fileIndex,
     1067                            tr_priority_t  priority )
    10641068{
    10651069    int i;
     
    10901094
    10911095    for( i=0; i<fileCount; ++i )
    1092         setFilePriority( tor, files[i], priority );
     1096        tr_torrentInitFilePriority( tor, files[i], priority );
    10931097
    10941098    saveFastResumeNow( tor );
  • trunk/libtransmission/torrent.h

    r4324 r4326  
    7878uint64_t tr_pieceOffset( const tr_torrent * tor, int index, int begin, int length );
    7979
     80void tr_torrentInitFilePriority( tr_torrent   * tor,
     81                                 int            fileIndex,
     82                                 tr_priority_t  priority );
     83
     84
    8085typedef enum
    8186{
Note: See TracChangeset for help on using the changeset viewer.