mirror of
https://github.com/transmission/transmission
synced 2025-03-07 03:58:11 +00:00
when a download finishes, stop and make wait if the seeding queue is full
This commit is contained in:
parent
806693281f
commit
c5a1a89df0
3 changed files with 122 additions and 92 deletions
|
@ -152,6 +152,9 @@
|
||||||
- (void) updateControlTint: (NSNotification *) notification;
|
- (void) updateControlTint: (NSNotification *) notification;
|
||||||
|
|
||||||
- (void) updateUI: (NSTimer *) timer;
|
- (void) updateUI: (NSTimer *) timer;
|
||||||
|
|
||||||
|
- (void) updateTorrentsInQueue;
|
||||||
|
|
||||||
- (void) torrentFinishedDownloading: (NSNotification *) notification;
|
- (void) torrentFinishedDownloading: (NSNotification *) notification;
|
||||||
- (void) updateTorrentHistory;
|
- (void) updateTorrentHistory;
|
||||||
|
|
||||||
|
@ -173,7 +176,6 @@
|
||||||
- (void) setQuickRatioGlobal: (id) sender;
|
- (void) setQuickRatioGlobal: (id) sender;
|
||||||
|
|
||||||
- (void) torrentStoppedForRatio: (NSNotification *) notification;
|
- (void) torrentStoppedForRatio: (NSNotification *) notification;
|
||||||
- (void) updateTorrentsInQueue;
|
|
||||||
|
|
||||||
- (void) changeAutoImport;
|
- (void) changeAutoImport;
|
||||||
- (void) checkAutoImportDirectory;
|
- (void) checkAutoImportDirectory;
|
||||||
|
|
|
@ -1135,14 +1135,97 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
[fBadger updateBadgeWithCompleted: fCompleted uploadRate: uploadRate downloadRate: downloadRate];
|
[fBadger updateBadgeWithCompleted: fCompleted uploadRate: uploadRate downloadRate: downloadRate];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) updateTorrentsInQueue
|
||||||
|
{
|
||||||
|
BOOL download = [fDefaults boolForKey: @"Queue"],
|
||||||
|
seed = [fDefaults boolForKey: @"QueueSeed"];
|
||||||
|
|
||||||
|
if (!download && !seed)
|
||||||
|
{
|
||||||
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||||
|
Torrent * torrent;
|
||||||
|
while ((torrent = [enumerator nextObject]))
|
||||||
|
if (![torrent isActive] && [torrent waitingToStart])
|
||||||
|
[torrent startTransfer];
|
||||||
|
|
||||||
|
[self updateUI: nil];
|
||||||
|
[self applyFilter: nil];
|
||||||
|
[self updateTorrentHistory];
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//determine the number of downloads needed to start
|
||||||
|
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 isError])
|
||||||
|
{
|
||||||
|
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 || desiredSeedActive > 0))
|
||||||
|
{
|
||||||
|
NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||||
|
@"orderValue" ascending: YES] autorelease];
|
||||||
|
NSArray * descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil];
|
||||||
|
|
||||||
|
sortedTorrents = [fTorrents sortedArrayUsingDescriptors: descriptors];
|
||||||
|
[descriptors release];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sortedTorrents = fTorrents;
|
||||||
|
|
||||||
|
enumerator = [sortedTorrents objectEnumerator];
|
||||||
|
while ((torrent = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
if (![torrent isActive] && [torrent waitingToStart])
|
||||||
|
{
|
||||||
|
if ([torrent progress] < 1.0)
|
||||||
|
{
|
||||||
|
if (!download || desiredDownloadActive > 0)
|
||||||
|
{
|
||||||
|
[torrent startTransfer];
|
||||||
|
if ([torrent isActive])
|
||||||
|
desiredDownloadActive--;
|
||||||
|
[torrent update];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!seed || desiredSeedActive > 0)
|
||||||
|
{
|
||||||
|
[torrent startTransfer];
|
||||||
|
if ([torrent isActive])
|
||||||
|
desiredSeedActive--;
|
||||||
|
[torrent update];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[self updateUI: nil];
|
||||||
|
[self applyFilter: nil];
|
||||||
|
[self updateTorrentHistory];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) torrentFinishedDownloading: (NSNotification *) notification
|
- (void) torrentFinishedDownloading: (NSNotification *) notification
|
||||||
{
|
{
|
||||||
Torrent * torrent = [notification object];
|
Torrent * torrent = [notification object];
|
||||||
|
|
||||||
[fInfoController updateInfoStats];
|
[fInfoController updateInfoStats];
|
||||||
|
|
||||||
[self updateTorrentsInQueue];
|
|
||||||
|
|
||||||
if ([fDefaults boolForKey: @"PlayDownloadSound"])
|
if ([fDefaults boolForKey: @"PlayDownloadSound"])
|
||||||
{
|
{
|
||||||
NSSound * sound;
|
NSSound * sound;
|
||||||
|
@ -1156,6 +1239,33 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
|
|
||||||
if (![fWindow isKeyWindow])
|
if (![fWindow isKeyWindow])
|
||||||
fCompleted++;
|
fCompleted++;
|
||||||
|
|
||||||
|
//update queue if there is a seeding queue
|
||||||
|
if ([fDefaults boolForKey: @"QueueSeed"])
|
||||||
|
{
|
||||||
|
int desiredSeedActive = [fDefaults integerForKey: @"QueueSeedNumber"];
|
||||||
|
|
||||||
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||||
|
Torrent * otherTorrent;
|
||||||
|
while ((otherTorrent = [enumerator nextObject]))
|
||||||
|
if (otherTorrent != torrent && [otherTorrent isSeeding] && [otherTorrent isActive] && ![otherTorrent isError])
|
||||||
|
{
|
||||||
|
desiredSeedActive--;
|
||||||
|
if (desiredSeedActive <= 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (desiredSeedActive <= 0)
|
||||||
|
{
|
||||||
|
[torrent stopTransfer];
|
||||||
|
[torrent setWaitToStart: YES];
|
||||||
|
[torrent update];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[self updateUI: nil];
|
||||||
|
[self applyFilter: nil];
|
||||||
|
[self updateTorrentHistory];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) updateTorrentHistory
|
- (void) updateTorrentHistory
|
||||||
|
@ -1576,91 +1686,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
notificationName: GROWL_SEEDING_COMPLETE iconData: nil priority: 0 isSticky: NO clickContext: nil];
|
notificationName: GROWL_SEEDING_COMPLETE iconData: nil priority: 0 isSticky: NO clickContext: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) updateTorrentsInQueue
|
|
||||||
{
|
|
||||||
BOOL download = [fDefaults boolForKey: @"Queue"],
|
|
||||||
seed = [fDefaults boolForKey: @"QueueSeed"];
|
|
||||||
|
|
||||||
if (!download && !seed)
|
|
||||||
{
|
|
||||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
|
||||||
Torrent * torrent;
|
|
||||||
while ((torrent = [enumerator nextObject]))
|
|
||||||
if (![torrent isActive] && [torrent waitingToStart])
|
|
||||||
[torrent startTransfer];
|
|
||||||
|
|
||||||
[self updateUI: nil];
|
|
||||||
[self applyFilter: nil];
|
|
||||||
[self updateTorrentHistory];
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//determine the number of downloads needed to start
|
|
||||||
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 isError])
|
|
||||||
{
|
|
||||||
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 || desiredSeedActive > 0))
|
|
||||||
{
|
|
||||||
NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
|
||||||
@"orderValue" ascending: YES] autorelease];
|
|
||||||
NSArray * descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil];
|
|
||||||
|
|
||||||
sortedTorrents = [fTorrents sortedArrayUsingDescriptors: descriptors];
|
|
||||||
[descriptors release];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
sortedTorrents = fTorrents;
|
|
||||||
|
|
||||||
enumerator = [sortedTorrents objectEnumerator];
|
|
||||||
while ((torrent = [enumerator nextObject]))
|
|
||||||
{
|
|
||||||
if (![torrent isActive] && [torrent waitingToStart])
|
|
||||||
{
|
|
||||||
if ([torrent progress] < 1.0)
|
|
||||||
{
|
|
||||||
if (!download || desiredDownloadActive > 0)
|
|
||||||
{
|
|
||||||
[torrent startTransfer];
|
|
||||||
if ([torrent isActive])
|
|
||||||
desiredDownloadActive--;
|
|
||||||
[torrent update];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!seed || desiredSeedActive > 0)
|
|
||||||
{
|
|
||||||
[torrent startTransfer];
|
|
||||||
if ([torrent isActive])
|
|
||||||
desiredSeedActive--;
|
|
||||||
[torrent update];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[self updateUI: nil];
|
|
||||||
[self applyFilter: nil];
|
|
||||||
[self updateTorrentHistory];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void) watcher: (id<UKFileWatcher>) watcher receivedNotification: (NSString *) notification forPath: (NSString *) path
|
-(void) watcher: (id<UKFileWatcher>) watcher receivedNotification: (NSString *) notification forPath: (NSString *) path
|
||||||
{
|
{
|
||||||
if ([notification isEqualToString: UKFileWatcherWriteNotification])
|
if ([notification isEqualToString: UKFileWatcherWriteNotification])
|
||||||
|
|
|
@ -290,11 +290,14 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
NSString * tempString;
|
NSString * tempString;
|
||||||
|
|
||||||
case TR_STATUS_PAUSE:
|
case TR_STATUS_PAUSE:
|
||||||
if (fFinishedSeeding)
|
if (fWaitToStart)
|
||||||
|
{
|
||||||
|
tempString = [self progress] < 1.0
|
||||||
|
? [NSLocalizedString(@"Waiting to start", "Torrent -> status string") stringByAppendingEllipsis]
|
||||||
|
: [NSLocalizedString(@"Waiting to seed", "Torrent -> status string") stringByAppendingEllipsis];
|
||||||
|
}
|
||||||
|
else if (fFinishedSeeding)
|
||||||
tempString = NSLocalizedString(@"Seeding complete", "Torrent -> status string");
|
tempString = NSLocalizedString(@"Seeding complete", "Torrent -> status string");
|
||||||
#warning differentiate seed waiting
|
|
||||||
else if (fWaitToStart)
|
|
||||||
tempString = [NSLocalizedString(@"Waiting to start", "Torrent -> status string") stringByAppendingEllipsis];
|
|
||||||
else
|
else
|
||||||
tempString = NSLocalizedString(@"Paused", "Torrent -> status string");
|
tempString = NSLocalizedString(@"Paused", "Torrent -> status string");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue