Changeset 8469


Ignore:
Timestamp:
May 22, 2009, 1:21:56 AM (12 years ago)
Author:
charles
Message:

(trunk libT) take out the test scaffolding for the tr_torrentFiles() rewrite

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r8468 r8469  
    667667    tr_metainfoMigrate( session, &tor->info );
    668668
    669 {
    670     /* exercise the new tr_torrentFiles() code in the nightly builds...
    671        maybe this will make rolcol stay in-channel */
    672     tr_file_index_t tmpCount;
    673     tr_file_stat * tmp = tr_torrentFiles( tor, &tmpCount );
    674     tr_torrentFilesFree( tmp, tmpCount );
    675 }
    676 
    677669    if( doStart )
    678670        torrentStart( tor, FALSE );
     
    989981****
    990982***/
    991 
    992 static uint64_t
    993 oldFileBytesCompleted( const tr_torrent * tor,
    994                     tr_file_index_t    fileIndex )
    995 {
    996     const tr_file *        file     =  &tor->info.files[fileIndex];
    997     const tr_block_index_t firstBlock       =  file->offset /
    998                                               tor->blockSize;
    999     const uint64_t         firstBlockOffset =  file->offset %
    1000                                               tor->blockSize;
    1001     const uint64_t         lastOffset       =
    1002         file->length ? ( file->length - 1 ) : 0;
    1003     const tr_block_index_t lastBlock        =
    1004         ( file->offset + lastOffset ) / tor->blockSize;
    1005     const uint64_t         lastBlockOffset  =
    1006         ( file->offset + lastOffset ) % tor->blockSize;
    1007     uint64_t               haveBytes = 0;
    1008 
    1009     assert( tr_isTorrent( tor ) );
    1010     assert( fileIndex < tor->info.fileCount );
    1011     assert( file->offset + file->length <= tor->info.totalSize );
    1012     assert( ( firstBlock < tor->blockCount )
    1013           || ( !file->length && file->offset == tor->info.totalSize ) );
    1014     assert( ( lastBlock < tor->blockCount )
    1015           || ( !file->length && file->offset == tor->info.totalSize ) );
    1016     assert( firstBlock <= lastBlock );
    1017     assert( tr_torBlockPiece( tor, firstBlock ) == file->firstPiece );
    1018     assert( tr_torBlockPiece( tor, lastBlock ) == file->lastPiece );
    1019 
    1020     if( firstBlock == lastBlock )
    1021     {
    1022         if( tr_cpBlockIsCompleteFast( &tor->completion, firstBlock ) )
    1023             haveBytes += lastBlockOffset + 1 - firstBlockOffset;
    1024     }
    1025     else
    1026     {
    1027         tr_block_index_t i;
    1028 
    1029         if( tr_cpBlockIsCompleteFast( &tor->completion, firstBlock ) )
    1030             haveBytes += tor->blockSize - firstBlockOffset;
    1031 
    1032         for( i = firstBlock + 1; i < lastBlock; ++i )
    1033             if( tr_cpBlockIsCompleteFast( &tor->completion, i ) )
    1034                 haveBytes += tor->blockSize;
    1035 
    1036         if( tr_cpBlockIsCompleteFast( &tor->completion, lastBlock ) )
    1037             haveBytes += lastBlockOffset + 1;
    1038     }
    1039 
    1040     return haveBytes;
    1041 }
    1042983
    1043984static uint64_t
     
    11051046                total += ( f->offset + f->length ) - ( tor->blockSize * lastBlock );
    11061047        }
    1107     }
    1108 
    1109     if ( total != oldFileBytesCompleted( tor, index ) )
    1110     {
    1111 fprintf( stderr, "torrent is [%s], file #%d\n", tor->info.name, (int)index );
    1112 fprintf( stderr, "total size  is %"PRIu64"\n", (uint64_t)tor->info.totalSize );
    1113 fprintf( stderr, "block size  is %"PRIu64"\n", (uint64_t)tor->blockSize );
    1114 fprintf( stderr, "piece size  is %"PRIu64"\n", (uint64_t)tor->info.pieceSize );
    1115 fprintf( stderr, "file offset is %"PRIu64"\n", (uint64_t)f->offset );
    1116 fprintf( stderr, "file size   is %"PRIu64"\n", (uint64_t)f->length );
    1117 fprintf( stderr, " old size   is %"PRIu64"\n", (uint64_t)oldFileBytesCompleted( tor, index ) );
    1118 fprintf( stderr, "first piece is %"PRIu64"\n", (uint64_t)f->firstPiece );
    1119 fprintf( stderr, "last piece  is %"PRIu64"\n", (uint64_t)f->lastPiece );
    1120 fprintf( stderr, " new size   is %"PRIu64"\n", (uint64_t)total );
    1121 abort( );
    11221048    }
    11231049
Note: See TracChangeset for help on using the changeset viewer.