Changeset 5614
- Timestamp:
- Apr 14, 2008, 3:17:16 PM (14 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/resume.c
r5613 r5614 27 27 #define KEY_CORRUPT "corrupt" 28 28 #define KEY_DESTINATION "destination" 29 #define KEY_DND "dnd" 29 30 #define KEY_DOWNLOADED "downloaded" 30 31 #define KEY_MAX_PEERS "max-peers" … … 101 102 102 103 static void 103 save Priorities( tr_benc * dict, const tr_torrent * tor )104 saveDND( tr_benc * dict, const tr_torrent * tor ) 104 105 { 105 106 const tr_info * inf = &tor->info; … … 108 109 tr_benc * list; 109 110 110 list = tr_bencDictAddList( dict, KEY_PRIORITY, tor->info.fileCount ); 111 list = tr_bencDictAddList( dict, KEY_DND, n ); 112 for( i=0; i<n; ++i ) 113 tr_bencInitInt( tr_bencListAdd( list ), inf->files[i].dnd ? 1 : 0 ); 114 } 115 116 static uint64_t 117 loadDND( tr_benc * dict, tr_torrent * tor ) 118 { 119 uint64_t ret = 0; 120 tr_info * inf = &tor->info; 121 const tr_file_index_t n = inf->fileCount; 122 tr_benc * list; 123 124 if( tr_bencDictFindList( dict, KEY_DND, &list ) 125 && ( list->val.l.count == (int)n ) ) 126 { 127 int64_t tmp; 128 tr_file_index_t * dl = tr_new( tr_file_index_t, n ); 129 tr_file_index_t * dnd = tr_new( tr_file_index_t, n ); 130 tr_file_index_t i, dlCount=0, dndCount=0; 131 132 for( i=0; i<n; ++i ) { 133 if( tr_bencGetInt( &list->val.l.vals[i], &tmp ) && tmp ) 134 dnd[dndCount++] = i; 135 else 136 dl[dlCount++] = i; 137 } 138 139 if( dndCount ) 140 tr_torrentInitFileDLs ( tor, dnd, dndCount, FALSE ); 141 if( dlCount ) 142 tr_torrentInitFileDLs ( tor, dl, dlCount, TRUE ); 143 144 tr_free( dnd ); 145 tr_free( dl ); 146 ret = TR_FR_PRIORITY; 147 } 148 149 return ret; 150 } 151 152 /*** 153 **** 154 ***/ 155 156 static void 157 savePriorities( tr_benc * dict, const tr_torrent * tor ) 158 { 159 const tr_info * inf = &tor->info; 160 const tr_file_index_t n = inf->fileCount; 161 tr_file_index_t i; 162 tr_benc * list; 163 164 list = tr_bencDictAddList( dict, KEY_PRIORITY, n ); 111 165 for( i=0; i<n; ++i ) 112 166 tr_bencInitInt( tr_bencListAdd( list ), inf->files[i].priority ); … … 297 351 savePeers( &top, tor ); 298 352 savePriorities( &top, tor ); 353 saveDND( &top, tor ); 299 354 saveProgress( &top, tor ); 300 355 saveSpeedLimits( &top, tor ); … … 382 437 fieldsLoaded |= loadProgress( &top, tor ); 383 438 439 if( fieldsToLoad & TR_FR_DND ) 440 fieldsLoaded |= loadDND( &top, tor ); 441 384 442 if( fieldsToLoad & TR_FR_SPEEDLIMIT ) 385 443 fieldsLoaded |= loadSpeedLimits( &top, tor ); -
trunk/libtransmission/resume.h
r5606 r5614 21 21 TR_FR_PEERS = (1<<3), 22 22 TR_FR_PROGRESS = (1<<4), 23 TR_FR_PRIORITY = (1<<5), 24 TR_FR_SPEEDLIMIT = (1<<6), 25 TR_FR_RUN = (1<<7), 26 TR_FR_DESTINATION = (1<<8), 27 TR_FR_MAX_PEERS = (1<<9) 23 TR_FR_DND = (1<<5), 24 TR_FR_PRIORITY = (1<<6), 25 TR_FR_SPEEDLIMIT = (1<<7), 26 TR_FR_RUN = (1<<8), 27 TR_FR_DESTINATION = (1<<9), 28 TR_FR_MAX_PEERS = (1<<10) 28 29 }; 29 30
Note: See TracChangeset
for help on using the changeset viewer.