Ignore:
Timestamp:
Jan 12, 2009, 9:59:53 PM (13 years ago)
Author:
charles
Message:

(trunk libT) close open files immediately after they're done downloading

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/completion.c

    r7647 r7692  
    316316    return cp->completeBlocks[piece] == tr_torPieceCountBlocks( cp->tor, piece );
    317317}
     318
     319tr_bool
     320tr_cpFileIsComplete( const tr_completion * cp, tr_file_index_t fileIndex )
     321{
     322    tr_block_index_t block;
     323
     324    const tr_torrent * tor = cp->tor;
     325    const tr_file * file = &tor->info.files[fileIndex];
     326    const tr_block_index_t firstBlock = file->offset / tor->blockSize;
     327    const tr_block_index_t lastBlock = ( file->offset + file->length - 1 ) / tor->blockSize;
     328
     329    assert( tr_torBlockPiece( tor, firstBlock ) == file->firstPiece );
     330    assert( tr_torBlockPiece( tor, lastBlock ) == file->lastPiece );
     331
     332    for( block=firstBlock; block<=lastBlock; ++block )
     333        if( !tr_cpBlockIsComplete( cp, block ) )
     334            return FALSE;
     335
     336    return TRUE;
     337}
Note: See TracChangeset for help on using the changeset viewer.