another queue adjustment
This commit is contained in:
parent
26c79a5d43
commit
cc7d0e3caf
|
@ -1561,7 +1561,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
|
|
||||||
- (void) torrentStoppedForRatio: (NSNotification *) notification
|
- (void) torrentStoppedForRatio: (NSNotification *) notification
|
||||||
{
|
{
|
||||||
[self applyFilter: nil];
|
[self updateTorrentsInQueue];
|
||||||
[fInfoController updateInfoStats];
|
[fInfoController updateInfoStats];
|
||||||
|
|
||||||
if ([fDefaults boolForKey: @"PlaySeedingSound"])
|
if ([fDefaults boolForKey: @"PlaySeedingSound"])
|
||||||
|
@ -1581,7 +1581,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
[self updateTorrentsInQueue];
|
[self updateTorrentsInQueue];
|
||||||
}
|
}
|
||||||
|
|
||||||
//will try to start, taking into consideration the start preference
|
|
||||||
- (void) updateTorrentsInQueue
|
- (void) updateTorrentsInQueue
|
||||||
{
|
{
|
||||||
if (![fDefaults boolForKey: @"Queue"])
|
if (![fDefaults boolForKey: @"Queue"])
|
||||||
|
@ -1600,38 +1599,44 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
}
|
}
|
||||||
|
|
||||||
//determine the number of downloads needed to start
|
//determine the number of downloads needed to start
|
||||||
int desiredActive = [fDefaults integerForKey: @"QueueDownloadNumber"];
|
int desiredDownloadActive = [fDefaults integerForKey: @"QueueDownloadNumber"];
|
||||||
|
|
||||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||||
Torrent * torrent;
|
Torrent * torrent;
|
||||||
while ((torrent = [enumerator nextObject]))
|
while ((torrent = [enumerator nextObject]))
|
||||||
if ([torrent isActive] && ![torrent isSeeding] && ![torrent isError])
|
if ([torrent isActive] && ![torrent isSeeding] && ![torrent isError])
|
||||||
{
|
{
|
||||||
desiredActive--;
|
desiredDownloadActive--;
|
||||||
if (desiredActive <= 0)
|
if (desiredDownloadActive <= 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//sort torrents by order value
|
//sort torrents by order value
|
||||||
NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
NSArray * sortedTorrents;
|
||||||
|
if ([fTorrents count] > 1 && desiredDownloadActive > 0)
|
||||||
|
{
|
||||||
|
NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||||
@"orderValue" ascending: YES] autorelease];
|
@"orderValue" ascending: YES] autorelease];
|
||||||
NSArray * descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil];
|
NSArray * descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil];
|
||||||
|
|
||||||
NSArray * sortedTorrents = [fTorrents sortedArrayUsingDescriptors: descriptors];
|
sortedTorrents = [fTorrents sortedArrayUsingDescriptors: descriptors];
|
||||||
[descriptors release];
|
[descriptors release];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sortedTorrents = fTorrents;
|
||||||
|
|
||||||
enumerator = [sortedTorrents objectEnumerator];
|
enumerator = [sortedTorrents objectEnumerator];
|
||||||
while ((torrent = [enumerator nextObject]))
|
while ((torrent = [enumerator nextObject]))
|
||||||
{
|
{
|
||||||
if ([torrent waitingToStart])
|
if (![torrent isActive] && [torrent waitingToStart])
|
||||||
{
|
{
|
||||||
if ([torrent progress] >= 1.0)
|
if ([torrent progress] >= 1.0)
|
||||||
[torrent startTransfer];
|
[torrent startTransfer];
|
||||||
else if (desiredActive > 0)
|
else if (desiredDownloadActive > 0)
|
||||||
{
|
{
|
||||||
[torrent startTransfer];
|
[torrent startTransfer];
|
||||||
if ([torrent isActive])
|
if ([torrent isActive])
|
||||||
desiredActive--;
|
desiredDownloadActive--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue