Ignore:
Timestamp:
May 6, 2008, 1:43:24 AM (14 years ago)
Author:
charles
Message:

#912: Resume file parsed twice on startup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/verify.c

    r5606 r5750  
    5757}
    5858
    59 static void
     59static int
    6060checkFile( tr_torrent       * tor,
    6161           tr_file_index_t    fileIndex,
     
    6363{
    6464    tr_piece_index_t i;
     65    int changed = FALSE;
    6566    int nofile;
    6667    struct stat sb;
     
    7980        else if( !tr_torrentIsPieceChecked( tor, i ) )
    8081        {
     82            const int wasComplete = tr_cpPieceIsComplete( tor->completion, i );
    8183            const tr_errno err = tr_ioTestPiece( tor, i );
    8284
     
    8486            {
    8587                tr_torrentSetHasPiece( tor, i, TRUE );
     88                if( !wasComplete )
     89                    changed = TRUE;
    8690            }
    8791            else
     
    9296                 * want to lose blocks in those incomplete pieces */
    9397
    94                 if( tr_cpPieceIsComplete( tor->completion, i ) )
     98                if( wasComplete ) {
    9599                    tr_torrentSetHasPiece( tor, i, FALSE );
     100                    changed = TRUE;
     101                }
    96102            }
    97103        }
     
    99105        tr_torrentSetPieceChecked( tor, i, TRUE );
    100106    }
     107
     108    return changed;
    101109}
    102110
     
    106114    for( ;; )
    107115    {
     116        int changed = 0;
    108117        tr_file_index_t i;
    109118        tr_torrent * tor;
     
    128137        tr_torinf( tor, _( "Verifying torrent" ) );
    129138        for( i=0; i<tor->info.fileCount && !stopCurrent; ++i )
    130             checkFile( tor, i, &stopCurrent );
     139            changed |= checkFile( tor, i, &stopCurrent );
    131140
    132141        tor->verifyState = TR_VERIFY_NONE;
     
    134143        if( !stopCurrent )
    135144        {
    136             tr_torrentSaveResume( tor );
     145            if( changed )
     146                tr_torrentSaveResume( tor );
    137147            fireCheckDone( tor, currentNode.verify_done_cb );
    138148        }
Note: See TracChangeset for help on using the changeset viewer.