make tr_torrentGetFileStatus() more accurate

This commit is contained in:
Charles Kerr 2007-07-15 18:47:43 +00:00
parent ad6ae58e06
commit 4a0c4b6fbc
1 changed files with 3 additions and 15 deletions

View File

@ -1284,22 +1284,10 @@ tr_torrentSetFileDLs ( tr_torrent_t * tor,
cp_status_t cp_status_t
tr_torrentGetFileStatus( const tr_torrent_t * tor, int fileIndex ) tr_torrentGetFileStatus( const tr_torrent_t * tor, int fileIndex )
{ {
int i; const uint64_t bytes = tr_torrentFileBytesCompleted( tor, fileIndex );
int isComplete; const tr_file_t * file = &tor->info.files[fileIndex];
const tr_file_t * file;
assert( tor != NULL ); if( bytes >= file->length )
assert( 0<=fileIndex );
assert( fileIndex<tor->info.fileCount );
file = &tor->info.files[fileIndex];
isComplete = TRUE;
for( i=file->firstPiece; isComplete && i<=file->lastPiece; ++i )
if( !tr_cpPieceIsComplete( tor->completion, i ) )
isComplete = FALSE;
if( isComplete )
return TR_CP_COMPLETE; return TR_CP_COMPLETE;
if( file->dnd ) if( file->dnd )