Changeset 10387
- Timestamp:
- Mar 15, 2010, 11:29:56 PM (12 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/completion.c
r9868 r10387 165 165 } 166 166 167 168 void 169 tr_cpSetHaveAll( tr_completion * cp ) 170 { 171 tr_piece_index_t i; 172 tr_torrent * tor = cp->tor; 173 174 tr_cpReset( cp ); 175 176 cp->sizeNow = tor->info.totalSize; 177 tr_bitfieldAddRange( &cp->blockBitfield, 0, tor->blockCount ); 178 tr_bitfieldAddRange( &cp->pieceBitfield, 0, tor->info.pieceCount ); 179 for( i=0; i<tor->info.pieceCount; ++i ) 180 cp->completeBlocks[i] = tr_torPieceCountBlocks( tor, i ); 181 cp->sizeWhenDoneIsDirty = 1; 182 cp->haveValidIsDirty = 1; 183 } 184 167 185 /* Initialize a completion object from a bitfield indicating which blocks we have */ 168 186 tr_bool -
trunk/libtransmission/completion.h
r10031 r10387 158 158 struct tr_bitfield * blocks ); 159 159 160 void tr_cpSetHaveAll( tr_completion * completion ); 161 160 162 /*** 161 163 **** -
trunk/libtransmission/resume.c
r10084 r10387 56 56 #define KEY_RATIOLIMIT_MODE "ratio-mode" 57 57 58 #define KEY_PROGRESS_MTIMES "mtimes" 59 #define KEY_PROGRESS_BITFIELD "bitfield" 58 #define KEY_PROGRESS_MTIMES "mtimes" 59 #define KEY_PROGRESS_BITFIELD "bitfield" 60 #define KEY_PROGRESS_HAVE "have" 60 61 61 62 enum … … 397 398 } 398 399 399 /* add the bitfield */ 400 /* add the progress */ 401 if( tor->completeness == TR_SEED ) 402 tr_bencDictAddStr( p, KEY_PROGRESS_HAVE, "all" ); 400 403 bitfield = tr_cpBlockBitfield( &tor->completion ); 401 404 tr_bencDictAddRaw( p, KEY_PROGRESS_BITFIELD, … … 415 418 if( tr_bencDictFindDict( dict, KEY_PROGRESS, &p ) ) 416 419 { 420 const char * err; 421 const char * str; 417 422 const uint8_t * raw; 418 423 size_t rawlen; … … 460 465 } 461 466 462 if( tr_bencDictFindRaw( p, KEY_PROGRESS_BITFIELD, &raw, &rawlen ) ) 467 err = NULL; 468 if( tr_bencDictFindStr( p, KEY_PROGRESS_HAVE, &str ) ) 469 { 470 if( !strcmp( str, "all" ) ) 471 tr_cpSetHaveAll( &tor->completion ); 472 else 473 err = "Invalid value for HAVE"; 474 } 475 else if( tr_bencDictFindRaw( p, KEY_PROGRESS_BITFIELD, &raw, &rawlen ) ) 463 476 { 464 477 tr_bitfield tmp; … … 467 480 tmp.bits = (uint8_t*) raw; 468 481 if( !tr_cpBlockBitfieldSet( &tor->completion, &tmp ) ) 469 { 470 tr_torrentUncheck( tor ); 471 tr_tordbg( 472 tor, 473 "Torrent needs to be verified - error loading bitfield" ); 474 } 475 } 476 else 477 { 482 err = "Error loading bitfield"; 483 } 484 else err = "Couldn't find 'have' or 'bitfield'"; 485 if( err != NULL ) 486 { 478 487 tr_torrentUncheck( tor ); 479 tr_tordbg( 480 tor, 481 "Torrent needs to be verified - unable to find bitfield" ); 488 tr_tordbg( tor, "Torrent needs to be verified - %s", err ); 482 489 } 483 490
Note: See TracChangeset
for help on using the changeset viewer.