Changeset 12012 for trunk/libtransmission/cache.c
- Timestamp:
- Feb 23, 2011, 3:54:04 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/cache.c
r11782 r12012 390 390 391 391 static int 392 find Piece( tr_cache * cache, tr_torrent * torrent, tr_piece_index_t piece)392 findBlockPos( tr_cache * cache, tr_torrent * torrent, tr_piece_index_t block ) 393 393 { 394 394 struct cache_block key; 395 395 key.tor = torrent; 396 key.block = tr_torPieceFirstBlock( torrent, piece );396 key.block = block; 397 397 return tr_ptrArrayLowerBound( &cache->blocks, &key, cache_block_compare, NULL ); 398 398 } … … 420 420 tr_cacheFlushFile( tr_cache * cache, tr_torrent * torrent, tr_file_index_t i ) 421 421 { 422 int err = 0; 423 const tr_file * file = &torrent->info.files[i]; 424 const tr_block_index_t begin = tr_torPieceFirstBlock( torrent, file->firstPiece ); 425 const tr_block_index_t end = tr_torPieceFirstBlock( torrent, file->lastPiece ) + tr_torPieceCountBlocks( torrent, file->lastPiece ); 426 const int pos = findPiece( cache, torrent, file->firstPiece ); 427 dbgmsg( "flushing file %d from cache to disk: blocks [%zu...%zu)", (int)i, (size_t)begin, (size_t)end ); 422 int pos; 423 int err = 0; 424 tr_block_index_t first; 425 tr_block_index_t last; 426 tr_torGetFileBlockRange( torrent, i, &first, &last ); 427 pos = findBlockPos( cache, torrent, first ); 428 dbgmsg( "flushing file %d from cache to disk: blocks [%zu...%zu]", (int)i, (size_t)first, (size_t)last ); 428 429 429 430 /* flush out all the blocks in that file */ … … 432 433 const struct cache_block * b = tr_ptrArrayNth( &cache->blocks, pos ); 433 434 if( b->tor != torrent ) break; 434 if( ( b->block < begin ) || ( b->block >= end) ) break;435 if( ( b->block < first ) || ( b->block > last ) ) break; 435 436 err = flushContiguous( cache, pos, getBlockRun( cache, pos, NULL ) ); 436 437 } … … 443 444 { 444 445 int err = 0; 445 const int pos = find Piece( cache, torrent, 0 );446 const int pos = findBlockPos( cache, torrent, 0 ); 446 447 447 448 /* flush out all the blocks in that torrent */
Note: See TracChangeset
for help on using the changeset viewer.