Changeset 4153


Ignore:
Timestamp:
Dec 13, 2007, 5:28:13 PM (14 years ago)
Author:
charles
Message:

accept tiennou's file-checking tweak that clarifies the log messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/inout.c

    r3988 r4153  
    248248        || memcmp( hash, tor->info.pieces[pieceIndex].hash, SHA_DIGEST_LENGTH );
    249249    tr_dbg ("torrent [%s] piece %d hash check: %s",
    250             tor->info.name, pieceIndex, (ret?"FAILED":"OK"));
    251     return ret;
     250            tor->info.name, pieceIndex, ( ret ? "FAILED" : "OK" ));
     251    return ret;
     252}
     253
     254static void
     255checkFile( tr_torrent   * tor,
     256           int            fileIndex,
     257           tr_bitfield  * uncheckedPieces,
     258           int          * abortFlag )
     259{
     260    int i;
     261    int nofile;
     262    struct stat sb;
     263    char path[MAX_PATH_LENGTH];
     264    const tr_file * file = &tor->info.files[fileIndex];
     265
     266    tr_buildPath ( path, sizeof(path), tor->destination, file->name, NULL );
     267    nofile = stat( path, &sb ) || !S_ISREG( sb.st_mode );
     268
     269    for( i=file->firstPiece; i<file->lastPiece && (!*abortFlag); ++i )
     270    {
     271        if( nofile )
     272        {
     273            tr_torrentSetHasPiece( tor, i, 0 );
     274        }
     275        else if( tr_bitfieldHas( uncheckedPieces, i ) )
     276        {
     277            const int check = checkPiece( tor, i );
     278            tr_torrentSetHasPiece( tor, i, !check );
     279            tr_bitfieldRem( uncheckedPieces, i );
     280        }
     281    }
    252282}
    253283
     
    352382
    353383        tr_inf( "Verifying some pieces of \"%s\"", tor->info.name );
    354 
    355         for( i=0; i<tor->info.pieceCount && !stopCurrent; ++i )
    356         {
    357             if( !tr_bitfieldHas( tor->uncheckedPieces, i ) )
    358                 continue;
    359 
    360             tr_torrentSetHasPiece( tor, i, !checkPiece( tor, i ) );
    361             tr_bitfieldRem( tor->uncheckedPieces, i );
    362         }
     384        for( i=0; i<tor->info.fileCount && !stopCurrent; ++i )
     385            checkFile( tor, i, tor->uncheckedPieces, &stopCurrent );
    363386
    364387        tor->recheckState = TR_RECHECK_NONE;
Note: See TracChangeset for help on using the changeset viewer.