fix dnd-setting bug created while splitting DND and priorities into two separate entities

This commit is contained in:
Charles Kerr 2007-07-10 03:41:16 +00:00
parent 2dc3f8b8f0
commit adb3d2399b
3 changed files with 36 additions and 4 deletions

View File

@ -255,6 +255,7 @@ fastResumeLoadPriorities( tr_torrent_t * tor,
default: priority = TR_PRI_NORMAL; break;
}
tor->info.files[i].priority = priority;
fprintf( stderr, "file %d has a priority of %d\n", (int)i, tor->info.files[i].priority );
}
/* set the dnd flags */

View File

@ -1203,13 +1203,40 @@ tr_torrentGetFileDL( const tr_torrent_t * tor,
void
tr_torrentSetFileDL( tr_torrent_t * tor,
int file,
int fileIndex,
int do_download )
{
int i;
tr_file_t * file;
const int dnd = !do_download;
tr_torrentWriterLock( tor );
assert( 0<=file && file<tor->info.fileCount );
tor->info.files[file].dnd = !do_download;
assert( 0<=fileIndex && fileIndex<tor->info.fileCount );
file = &tor->info.files[fileIndex];
file->dnd = dnd;
for( i=file->firstPiece; i<=file->lastPiece; ++i )
tor->info.pieces[i].dnd = dnd;
fastResumeSave( tor );
tr_torrentWriterUnlock( tor );
}
void
tr_torrentSetFileDLs ( tr_torrent_t * tor, const uint8_t * enabled )
{
int i, j;
tr_torrentWriterLock( tor );
for( i=0; i<tor->info.fileCount; ++i ) {
const int dnd = !enabled[i];
tr_file_t * file = &tor->info.files[i];
file->dnd = dnd;
for( j=file->firstPiece; j<=file->lastPiece; ++j )
tor->info.pieces[j].dnd = dnd;
}
fastResumeSave( tor );
tr_torrentWriterUnlock( tor );

View File

@ -233,7 +233,11 @@ tr_priority_t tr_torrentGetFilePriority( const tr_torrent_t *, int file );
/* returns true if the file's `download' flag is set */
int tr_torrentGetFileDL( const tr_torrent_t *, int file );
/* set the specified file's `download' flag */
/* enabled should be an array of tor->info.fileCount bytes,
* each holding a nonzero value if the file is to be downloaded */
void tr_torrentSetFileDLs ( tr_torrent_t *, const uint8_t * enabled );
/* single-file form of tr_torrentSetFileDLs */
void tr_torrentSetFileDL( tr_torrent_t *, int file, int do_download );