separate queue for seeding torrents
This commit is contained in:
parent
cc7d0e3caf
commit
806693281f
|
@ -795,7 +795,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 waitingToStart])
|
||||
if (![torrent isActive] && [torrent waitingToStart])
|
||||
[torrents addObject: torrent];
|
||||
|
||||
[self resumeTorrentsNoWait: torrents];
|
||||
|
@ -1576,14 +1576,12 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
notificationName: GROWL_SEEDING_COMPLETE iconData: nil priority: 0 isSticky: NO clickContext: nil];
|
||||
}
|
||||
|
||||
- (void) attemptToStartAuto: (Torrent *) torrent
|
||||
{
|
||||
[self updateTorrentsInQueue];
|
||||
}
|
||||
|
||||
- (void) updateTorrentsInQueue
|
||||
{
|
||||
if (![fDefaults boolForKey: @"Queue"])
|
||||
BOOL download = [fDefaults boolForKey: @"Queue"],
|
||||
seed = [fDefaults boolForKey: @"QueueSeed"];
|
||||
|
||||
if (!download && !seed)
|
||||
{
|
||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||
Torrent * torrent;
|
||||
|
@ -1599,21 +1597,26 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
}
|
||||
|
||||
//determine the number of downloads needed to start
|
||||
int desiredDownloadActive = [fDefaults integerForKey: @"QueueDownloadNumber"];
|
||||
int desiredDownloadActive = download ? [fDefaults integerForKey: @"QueueDownloadNumber"] : 0,
|
||||
desiredSeedActive = seed ? [fDefaults integerForKey: @"QueueSeedNumber"] : 0;
|
||||
|
||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||
Torrent * torrent;
|
||||
while ((torrent = [enumerator nextObject]))
|
||||
if ([torrent isActive] && ![torrent isSeeding] && ![torrent isError])
|
||||
if ([torrent isActive] && ![torrent isError])
|
||||
{
|
||||
desiredDownloadActive--;
|
||||
if (desiredDownloadActive <= 0)
|
||||
if (![torrent isSeeding])
|
||||
desiredDownloadActive--;
|
||||
else
|
||||
desiredSeedActive--;
|
||||
|
||||
if (desiredDownloadActive <= 0 && desiredSeedActive <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
//sort torrents by order value
|
||||
NSArray * sortedTorrents;
|
||||
if ([fTorrents count] > 1 && desiredDownloadActive > 0)
|
||||
if ([fTorrents count] > 1 && (desiredDownloadActive > 0 || desiredSeedActive > 0))
|
||||
{
|
||||
NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||
@"orderValue" ascending: YES] autorelease];
|
||||
|
@ -1630,18 +1633,26 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
{
|
||||
if (![torrent isActive] && [torrent waitingToStart])
|
||||
{
|
||||
if ([torrent progress] >= 1.0)
|
||||
[torrent startTransfer];
|
||||
else if (desiredDownloadActive > 0)
|
||||
if ([torrent progress] < 1.0)
|
||||
{
|
||||
[torrent startTransfer];
|
||||
if ([torrent isActive])
|
||||
desiredDownloadActive--;
|
||||
if (!download || desiredDownloadActive > 0)
|
||||
{
|
||||
[torrent startTransfer];
|
||||
if ([torrent isActive])
|
||||
desiredDownloadActive--;
|
||||
[torrent update];
|
||||
}
|
||||
}
|
||||
else
|
||||
continue;
|
||||
|
||||
[torrent update];
|
||||
{
|
||||
if (!seed || desiredSeedActive > 0)
|
||||
{
|
||||
[torrent startTransfer];
|
||||
if ([torrent isActive])
|
||||
desiredSeedActive--;
|
||||
[torrent update];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,10 @@
|
|||
<false/>
|
||||
<key>QueueDownloadNumber</key>
|
||||
<integer>3</integer>
|
||||
<key>QueueSeed</key>
|
||||
<false/>
|
||||
<key>QueueSeedNumber</key>
|
||||
<integer>3</integer>
|
||||
<key>RatioCheck</key>
|
||||
<false/>
|
||||
<key>RatioLimit</key>
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
setGlobalLimit = id;
|
||||
setNat = id;
|
||||
setPort = id;
|
||||
setQueue = id;
|
||||
setQueueNumber = id;
|
||||
setRatioStop = id;
|
||||
setSound = id;
|
||||
|
@ -42,7 +43,8 @@
|
|||
fPortStatusField = NSTextField;
|
||||
fPortStatusImage = NSImageView;
|
||||
fPortStatusProgress = NSProgressIndicator;
|
||||
fQueueField = NSTextField;
|
||||
fQueueDownloadField = NSTextField;
|
||||
fQueueSeedField = NSTextField;
|
||||
fRatioStopField = NSTextField;
|
||||
fSeedingSoundPopUp = NSPopUpButton;
|
||||
fSpeedLimitDownloadField = NSTextField;
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>153</key>
|
||||
<string>57 332 563 268 0 0 1152 842 </string>
|
||||
<string>294 445 563 268 0 0 1152 842 </string>
|
||||
<key>28</key>
|
||||
<string>156 256 571 290 0 0 1152 842 </string>
|
||||
<key>41</key>
|
||||
<string>89 307 563 305 0 0 1152 842 </string>
|
||||
<string>206 430 563 305 0 0 1152 842 </string>
|
||||
<key>66</key>
|
||||
<string>294 507 563 144 0 0 1152 842 </string>
|
||||
</dict>
|
||||
|
@ -23,7 +23,7 @@
|
|||
</array>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>66</integer>
|
||||
<integer>41</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>8L127</string>
|
||||
|
|
Binary file not shown.
|
@ -39,7 +39,7 @@
|
|||
|
||||
IBOutlet NSPopUpButton * fFolderPopUp, * fIncompleteFolderPopUp, * fImportFolderPopUp,
|
||||
* fDownloadSoundPopUp, * fSeedingSoundPopUp;
|
||||
IBOutlet NSTextField * fRatioStopField, * fQueueField;
|
||||
IBOutlet NSTextField * fRatioStopField, * fQueueDownloadField, * fQueueSeedField;
|
||||
|
||||
NSArray * fSounds;
|
||||
|
||||
|
@ -64,6 +64,7 @@
|
|||
- (void) setSound: (id) sender;
|
||||
- (void) setUpdate: (id) sender;
|
||||
|
||||
- (void) setQueue: (id) sender;
|
||||
- (void) setQueueNumber: (id) sender;
|
||||
|
||||
- (void) setDownloadLocation: (id) sender;
|
||||
|
|
|
@ -156,7 +156,8 @@
|
|||
selector: @selector(updateNatStatus) userInfo: nil repeats: YES];
|
||||
|
||||
//set queue values
|
||||
[fQueueField setIntValue: [fDefaults integerForKey: @"QueueDownloadNumber"]];
|
||||
[fQueueDownloadField setIntValue: [fDefaults integerForKey: @"QueueDownloadNumber"]];
|
||||
[fQueueSeedField setIntValue: [fDefaults integerForKey: @"QueueSeedNumber"]];
|
||||
|
||||
//set update check
|
||||
NSString * updateCheck = [fDefaults stringForKey: @"UpdateCheck"];
|
||||
|
@ -450,24 +451,30 @@
|
|||
[fUpdater scheduleCheckWithInterval: seconds];
|
||||
}
|
||||
|
||||
- (void) setQueue: (id) sender
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateQueue" object: self];
|
||||
}
|
||||
|
||||
- (void) setQueueNumber: (id) sender
|
||||
{
|
||||
BOOL download = sender == fQueueDownloadField;
|
||||
|
||||
int limit = [sender intValue];
|
||||
if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", limit]] || limit < 0)
|
||||
{
|
||||
NSBeep();
|
||||
[sender setIntValue: [fDefaults integerForKey: @"QueueDownloadNumber"]];
|
||||
[sender setIntValue: [fDefaults integerForKey: download ? @"QueueDownloadNumber" : @"QueueSeedNumber"]];
|
||||
return;
|
||||
}
|
||||
|
||||
[fDefaults setInteger: limit forKey: @"QueueDownloadNumber"];
|
||||
[fDefaults setInteger: limit forKey: download ? @"QueueDownloadNumber" : @"QueueSeedNumber"];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateQueue" object: self];
|
||||
[self setQueue: nil];
|
||||
}
|
||||
|
||||
- (void) setDownloadLocation: (id) sender
|
||||
{
|
||||
//download folder
|
||||
switch ([fFolderPopUp indexOfSelectedItem])
|
||||
{
|
||||
case DOWNLOAD_FOLDER:
|
||||
|
|
|
@ -292,6 +292,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
case TR_STATUS_PAUSE:
|
||||
if (fFinishedSeeding)
|
||||
tempString = NSLocalizedString(@"Seeding complete", "Torrent -> status string");
|
||||
#warning differentiate seed waiting
|
||||
else if (fWaitToStart)
|
||||
tempString = [NSLocalizedString(@"Waiting to start", "Torrent -> status string") stringByAppendingEllipsis];
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue