Changeset 5641
- Timestamp:
- Apr 18, 2008, 12:47:13 PM (14 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/fastresume.c
r5616 r5641 662 662 } 663 663 664 static uint64_t665 setFromCtor( tr_torrent * tor, uint64_t fields, const tr_ctor * ctor, int mode )666 {667 uint64_t ret = 0;668 669 if( fields & TR_FR_RUN ) {670 uint8_t isPaused;671 if( !tr_ctorGetPaused( ctor, mode, &isPaused ) ) {672 tor->isRunning = !isPaused;673 ret |= TR_FR_RUN;674 }675 }676 677 if( fields & TR_FR_MAX_PEERS )678 if( !tr_ctorGetMaxConnectedPeers( ctor, mode, &tor->maxConnectedPeers ) )679 ret |= TR_FR_MAX_PEERS;680 681 if( fields & TR_FR_DESTINATION ) {682 const char * destination;683 if( !tr_ctorGetDestination( ctor, mode, &destination ) ) {684 ret |= TR_FR_DESTINATION;685 tr_free( tor->destination );686 tor->destination = tr_strdup( destination );687 }688 }689 690 return ret;691 }692 693 static uint64_t694 useManditoryFields( tr_torrent * tor, uint64_t fields, const tr_ctor * ctor )695 {696 return setFromCtor( tor, fields, ctor, TR_FORCE );697 }698 699 static uint64_t700 useFallbackFields( tr_torrent * tor, uint64_t fields, const tr_ctor * ctor )701 {702 return setFromCtor( tor, fields, ctor, TR_FALLBACK );703 }704 705 664 uint64_t 706 665 tr_fastResumeLoad( tr_torrent * tor, 707 uint64_t fieldsToLoad, 708 const tr_ctor * ctor ) 709 { 710 uint64_t ret = 0; 711 712 ret |= useManditoryFields( tor, fieldsToLoad, ctor ); 713 fieldsToLoad &= ~ret; 714 ret |= fastResumeLoadImpl( tor, fieldsToLoad ); 715 fieldsToLoad &= ~ret; 716 ret |= useFallbackFields( tor, fieldsToLoad, ctor ); 717 718 return ret; 666 uint64_t fieldsToLoad ) 667 { 668 return fastResumeLoadImpl( tor, fieldsToLoad ); 719 669 } 720 670 -
trunk/libtransmission/fastresume.h
r5616 r5641 30 30 */ 31 31 uint64_t tr_fastResumeLoad( tr_torrent * tor, 32 uint64_t fieldsToLoad, 33 const tr_ctor * ctor ); 32 uint64_t fieldsToLoad ); 34 33 35 34 void tr_fastResumeRemove( const tr_torrent * tor ); -
trunk/libtransmission/resume.c
r5627 r5641 348 348 char filename[MAX_PATH_LENGTH]; 349 349 350 tr_bencInitDict( &top, 1 0);350 tr_bencInitDict( &top, 12 ); 351 351 tr_bencDictAddInt( &top, KEY_CORRUPT, 352 352 tor->corruptPrev + tor->corruptCur ); … … 374 374 375 375 uint64_t 376 tr_torrentLoadResume( tr_torrent * tor, 377 uint64_t fieldsToLoad, 378 const tr_ctor * ctor ) 376 loadFromFile( tr_torrent * tor, 377 uint64_t fieldsToLoad ) 379 378 { 380 379 int64_t i; … … 389 388 { 390 389 tr_tordbg( tor, "Couldn't read \"%s\"; trying old format.", filename ); 391 fieldsLoaded = tr_fastResumeLoad( tor, fieldsToLoad , ctor);390 fieldsLoaded = tr_fastResumeLoad( tor, fieldsToLoad ); 392 391 393 392 if( ( fieldsLoaded != 0 ) && ( fieldsToLoad == ~(uint64_t)0 ) ) … … 459 458 } 460 459 460 static uint64_t 461 setFromCtor( tr_torrent * tor, uint64_t fields, const tr_ctor * ctor, int mode ) 462 { 463 uint64_t ret = 0; 464 465 if( fields & TR_FR_RUN ) { 466 uint8_t isPaused; 467 if( !tr_ctorGetPaused( ctor, mode, &isPaused ) ) { 468 tor->isRunning = !isPaused; 469 ret |= TR_FR_RUN; 470 } 471 } 472 473 if( fields & TR_FR_MAX_PEERS ) 474 if( !tr_ctorGetMaxConnectedPeers( ctor, mode, &tor->maxConnectedPeers ) ) 475 ret |= TR_FR_MAX_PEERS; 476 477 if( fields & TR_FR_DESTINATION ) { 478 const char * destination; 479 if( !tr_ctorGetDestination( ctor, mode, &destination ) ) { 480 ret |= TR_FR_DESTINATION; 481 tr_free( tor->destination ); 482 tor->destination = tr_strdup( destination ); 483 } 484 } 485 486 return ret; 487 } 488 489 static uint64_t 490 useManditoryFields( tr_torrent * tor, uint64_t fields, const tr_ctor * ctor ) 491 { 492 return setFromCtor( tor, fields, ctor, TR_FORCE ); 493 } 494 495 static uint64_t 496 useFallbackFields( tr_torrent * tor, uint64_t fields, const tr_ctor * ctor ) 497 { 498 return setFromCtor( tor, fields, ctor, TR_FALLBACK ); 499 } 500 501 uint64_t 502 tr_torrentLoadResume( tr_torrent * tor, 503 uint64_t fieldsToLoad, 504 const tr_ctor * ctor ) 505 { 506 uint64_t ret = 0; 507 508 ret |= useManditoryFields( tor, fieldsToLoad, ctor ); 509 fieldsToLoad &= ~ret; 510 ret |= loadFromFile( tor, fieldsToLoad ); 511 fieldsToLoad &= ~ret; 512 ret |= useFallbackFields( tor, fieldsToLoad, ctor ); 513 514 return ret; 515 } 516 461 517 void 462 518 tr_torrentRemoveResume( const tr_torrent * tor )
Note: See TracChangeset
for help on using the changeset viewer.