Changeset 3569


Ignore:
Timestamp:
Oct 26, 2007, 1:13:47 AM (14 years ago)
Author:
charles
Message:

Fix 0.90 cache bug that could cause "verify local files" to fail.

Location:
branches/0.9x
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/0.9x/NEWS

    r3557 r3569  
    55   + Fix 0.90 socket connection leak
    66   + Fix 0.90 OpenBSD build error
     7   + Fix 0.90 cache bug that could cause "verify local files" to fail.
    78   + Ensure only a single "?" is used for appending arguments to the announce and scrape URL
    89- OS X:
  • branches/0.9x/libtransmission/fastresume.c

    r3430 r3569  
    440440                        FILE              * file )
    441441{
    442     int i;
    443442    const size_t len = FR_PROGRESS_LEN( tor );
    444443    uint8_t * buf = calloc( len, 1 );
    445     uint8_t * walk = buf;
    446 
    447     if( len != fread( buf, 1, len, file ) ) {
     444    int ret = 0;
     445    int i;
     446
     447    if( len != fread( buf, 1, len, file ) )
     448    {
    448449        tr_inf( "Couldn't read from resume file" );
    449         free( buf );
    450         return TR_ERROR_IO_OTHER;
    451     }
    452 
    453     /* compare file mtimes */
    454     if (1) {
     450        tr_bitfieldAddRange( uncheckedPieces, 0, tor->info.pieceCount );
     451        ret = TR_ERROR_IO_OTHER;
     452    }
     453    else
     454    {
    455455        int n;
     456        tr_bitfield bitfield;
     457
     458        /* compare file mtimes */
    456459        tr_time_t * curMTimes = getMTimes( tor, &n );
     460        uint8_t * walk = buf;
    457461        const tr_time_t * oldMTimes = (const tr_time_t *) walk;
    458462        for( i=0; i<n; ++i ) {
    459             if ( curMTimes[i]!=oldMTimes[i] ) {
     463            if ( !curMTimes[i] || ( curMTimes[i] != oldMTimes[i] ) ) {
    460464                const tr_file * file = &tor->info.files[i];
    461465                tr_dbg( "File '%s' mtimes differ-- flagging pieces [%d..%d] for recheck",
     
    467471        free( curMTimes );
    468472        walk += n * sizeof(tr_time_t);
    469     }
    470 
    471     /* get the completion bitfield */
    472     if (1) {
    473         tr_bitfield bitfield;
     473
     474        /* get the completion bitfield */
    474475        memset( &bitfield, 0, sizeof bitfield );
    475476        bitfield.len = FR_BLOCK_BITFIELD_LEN( tor );
     
    486487
    487488    free( buf );
    488     return TR_OK;
     489    return ret;
    489490}
    490491
Note: See TracChangeset for help on using the changeset viewer.