diff --git a/macosx/Torrent.h b/macosx/Torrent.h index fa9589f78..a2c367b09 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -206,8 +206,9 @@ //methods require fileStats to have been updated recently to be accurate - (float) fileProgress: (int) index; -- (int) checkForFiles: (NSIndexSet *) indexSet; +- (BOOL) canChangeDownloadCheckForFile: (int) index; - (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet; +- (int) checkForFiles: (NSIndexSet *) indexSet; - (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet; - (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet; - (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index f0515635e..7f9d1e213 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -1301,21 +1301,9 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 return fileStat[index].progress; } -- (int) checkForFiles: (NSIndexSet *) indexSet +- (BOOL) canChangeDownloadCheckForFile: (int) index { - BOOL onState = NO, offState = NO; - int index; - for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index]) - { - if (tr_torrentGetFileDL(fHandle, index) || ![self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]]) - onState = YES; - else - offState = YES; - - if (onState == offState) - return NSMixedState; - } - return onState ? NSOnState : NSOffState; + return [self fileCount] > 1 && fileStat[index].completionStatus != TR_CP_COMPLETE; } - (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet @@ -1333,6 +1321,23 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 return NO; } +- (int) checkForFiles: (NSIndexSet *) indexSet +{ + BOOL onState = NO, offState = NO; + int index; + for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index]) + { + if (tr_torrentGetFileDL(fHandle, index) || ![self canChangeDownloadCheckForFile: index]) + onState = YES; + else + offState = YES; + + if (onState == offState) + return NSMixedState; + } + return onState ? NSOnState : NSOffState; +} + - (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet { int count = [indexSet count], i = 0, index; @@ -1369,8 +1374,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 { int index; for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index]) - if (priority == tr_torrentGetFilePriority(fHandle, index) - && [self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]]) + if (priority == tr_torrentGetFilePriority(fHandle, index) && [self canChangeDownloadCheckForFile: index]) return YES; return NO; } @@ -1383,7 +1387,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 int index, priority; for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index]) { - if (![self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]]) + if (![self canChangeDownloadCheckForFile: index]) continue; priority = tr_torrentGetFilePriority(fHandle, index);