From ce013148b06bd6c19510494744bc31b1b8fff5dc Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Fri, 29 Sep 2006 05:30:36 +0000 Subject: [PATCH] Torrents that have errors aren't counted in the queue, and when a torrent encounters an error the next torrent in the queue will start (even though that torrent might still be active). --- macosx/Controller.m | 4 ++-- macosx/Torrent.h | 2 +- macosx/Torrent.m | 23 ++++++++++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index 4ec20bbb9..20960601a 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1420,7 +1420,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy if ([torrent isActive]) { - if (![torrent isSeeding]) + if (![torrent isSeeding] && ![torrent isError]) { desiredActive--; if (desiredActive <= 0) @@ -1507,7 +1507,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy NSEnumerator * enumerator = [fTorrents objectEnumerator]; Torrent * torrent; while ((torrent = [enumerator nextObject])) - if ([torrent isActive] && ![torrent isSeeding]) + if ([torrent isActive] && ![torrent isSeeding] && ![torrent isError]) { desiredActive--; if (desiredActive <= 0) diff --git a/macosx/Torrent.h b/macosx/Torrent.h index 4e9b79c40..5885ccdb1 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -49,7 +49,7 @@ int fStopRatioSetting; float fRatioLimit; - BOOL fFinishedSeeding, fWaitToStart; + BOOL fFinishedSeeding, fWaitToStart, fError; int fOrderValue; } diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 7819fef54..3740e94b1 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -261,9 +261,21 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 break; } - if( fStat->error & TR_ETRACKER ) - [fStatusString setString: [@"Error: " stringByAppendingString: - [NSString stringWithUTF8String: fStat->trackerError]]]; + if (fStat->error & TR_ETRACKER) + { + [fStatusString setString: [@"Error: " stringByAppendingString: [NSString stringWithUTF8String: fStat->trackerError]]]; + if (!fError && [self isActive]) + { + fError = YES; + if (![self isSeeding]) + [[NSNotificationCenter defaultCenter] postNotificationName: @"StoppedDownloading" object: self]; + } + } + else + { + if (fError) + fError = NO; + } if ([self isActive]) { @@ -329,6 +341,8 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 - (void) stopTransfer { + fError = NO; + if ([self isActive]) { BOOL wasSeeding = [self isSeeding]; @@ -430,8 +444,6 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 NSLog(@"Volume: %@", volume); NSLog(@"Remaining disk space: %qu (%@)", remainingSpace, [NSString stringForFileSize: remainingSpace]); - NSLog(@"Progress: %f", [self progress]); - NSLog(@"Torrent total size: %qu (%@)", [self size], [NSString stringForFileSize: [self size]]); NSLog(@"Torrent remaining size: %qu (%@)", torrentRemaining, [NSString stringForFileSize: torrentRemaining]); if (volume && remainingSpace <= torrentRemaining) @@ -790,6 +802,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 fWaitToStart = waitToStart ? [waitToStart boolValue] : [fDefaults boolForKey: @"AutoStartDownload"]; fOrderValue = orderValue ? [orderValue intValue] : tr_torrentCount(fLib) - 1; + fError = NO; NSString * fileType = fInfo->multifile ? NSFileTypeForHFSTypeCode('fldr') : [[self name] pathExtension]; fIcon = [[NSWorkspace sharedWorkspace] iconForFileType: fileType];