mirror of
https://github.com/transmission/transmission
synced 2024-12-26 09:37:56 +00:00
determine queue order solely on order in the fTorrent array - this gets around potential problems when relaunching with less torrents
This commit is contained in:
parent
6d6a76d48a
commit
945978ee41
3 changed files with 27 additions and 59 deletions
|
@ -841,8 +841,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
if (add)
|
||||
{
|
||||
[torrent setOrderValue: [fTorrents count]]; //ensure that queue order is always sequential
|
||||
|
||||
[torrent update];
|
||||
[fTorrents addObject: torrent];
|
||||
[torrent release];
|
||||
|
@ -1216,7 +1214,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
[fTorrents removeObjectsInArray: torrents];
|
||||
|
||||
NSInteger lowestOrderValue = NSIntegerMax;
|
||||
for (Torrent * torrent in torrents)
|
||||
{
|
||||
//let's expand all groups that have removed items - they either don't exist anymore, are already expanded, or are collapsed (rpc)
|
||||
|
@ -1227,20 +1224,11 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
if (deleteTorrent)
|
||||
[torrent trashTorrent];
|
||||
|
||||
lowestOrderValue = MIN(lowestOrderValue, [torrent orderValue]);
|
||||
|
||||
[torrent closeRemoveTorrent];
|
||||
}
|
||||
|
||||
[torrents release];
|
||||
|
||||
//reset the order values if necessary
|
||||
if (lowestOrderValue < [fTorrents count])
|
||||
{
|
||||
for (NSInteger i = lowestOrderValue; i < [fTorrents count]; i++)
|
||||
[[fTorrents objectAtIndex: i] setOrderValue: i];
|
||||
}
|
||||
|
||||
[fTableView deselectAll: nil];
|
||||
|
||||
[self updateTorrentsInQueue];
|
||||
|
@ -1796,17 +1784,13 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
NSString * sortType = [fDefaults stringForKey: @"Sort"];
|
||||
const BOOL asc = ![fDefaults boolForKey: @"SortReverse"];
|
||||
|
||||
NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"orderValue" ascending: asc] autorelease];
|
||||
|
||||
NSArray * descriptors;
|
||||
if ([sortType isEqualToString: SORT_ORDER])
|
||||
descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil];
|
||||
else if ([sortType isEqualToString: SORT_NAME])
|
||||
NSArray * descriptors = nil;
|
||||
if ([sortType isEqualToString: SORT_NAME])
|
||||
{
|
||||
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: asc
|
||||
selector: @selector(compareFinder:)] autorelease];
|
||||
|
||||
descriptors = [[NSArray alloc] initWithObjects: nameDescriptor, orderDescriptor, nil];
|
||||
descriptors = [[NSArray alloc] initWithObjects: nameDescriptor, nil];
|
||||
}
|
||||
else if ([sortType isEqualToString: SORT_STATE])
|
||||
{
|
||||
|
@ -1817,7 +1801,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
* ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"ratio" ascending: !asc] autorelease];
|
||||
|
||||
descriptors = [[NSArray alloc] initWithObjects: stateDescriptor, progressDescriptor, ratioDescriptor,
|
||||
nameDescriptor, orderDescriptor, nil];
|
||||
nameDescriptor, nil];
|
||||
}
|
||||
else if ([sortType isEqualToString: SORT_PROGRESS])
|
||||
{
|
||||
|
@ -1829,7 +1813,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
* ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"ratio" ascending: asc] autorelease];
|
||||
|
||||
descriptors = [[NSArray alloc] initWithObjects: progressDescriptor, ratioProgressDescriptor, ratioDescriptor,
|
||||
nameDescriptor, orderDescriptor, nil];
|
||||
nameDescriptor, nil];
|
||||
}
|
||||
else if ([sortType isEqualToString: SORT_TRACKER])
|
||||
{
|
||||
|
@ -1838,7 +1822,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
* trackerDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"trackerAddressAnnounce" ascending: asc
|
||||
selector: @selector(localizedCaseInsensitiveCompare:)] autorelease];
|
||||
|
||||
descriptors = [[NSArray alloc] initWithObjects: trackerDescriptor, nameDescriptor, orderDescriptor, nil];
|
||||
descriptors = [[NSArray alloc] initWithObjects: trackerDescriptor, nameDescriptor, nil];
|
||||
}
|
||||
else if ([sortType isEqualToString: SORT_ACTIVITY])
|
||||
{
|
||||
|
@ -1846,16 +1830,19 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
NSSortDescriptor * activityDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"dateActivityOrAdd" ascending: !asc]
|
||||
autorelease];
|
||||
|
||||
descriptors = [[NSArray alloc] initWithObjects: rateDescriptor, activityDescriptor, orderDescriptor, nil];
|
||||
descriptors = [[NSArray alloc] initWithObjects: rateDescriptor, activityDescriptor, nil];
|
||||
}
|
||||
else
|
||||
else if ([sortType isEqualToString: SORT_DATE])
|
||||
{
|
||||
NSSortDescriptor * dateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"dateAdded" ascending: asc] autorelease];
|
||||
|
||||
descriptors = [[NSArray alloc] initWithObjects: dateDescriptor, orderDescriptor, nil];
|
||||
descriptors = [[NSArray alloc] initWithObjects: dateDescriptor, nil];
|
||||
}
|
||||
else; //no need to sort by queue order
|
||||
|
||||
//actually sort
|
||||
if (descriptors)
|
||||
{
|
||||
if ([fDefaults boolForKey: @"SortByGroup"])
|
||||
{
|
||||
for (TorrentGroup * group in fDisplayedTorrents)
|
||||
|
@ -1865,6 +1852,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
[fDisplayedTorrents sortUsingDescriptors: descriptors];
|
||||
|
||||
[descriptors release];
|
||||
}
|
||||
|
||||
[fTableView reloadData];
|
||||
}
|
||||
|
@ -2718,10 +2706,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
NSUInteger insertIndex = topTorrent ? [fTorrents indexOfObject: topTorrent] + 1 : 0;
|
||||
NSIndexSet * insertIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(insertIndex, [movingTorrents count])];
|
||||
[fTorrents insertObjects: movingTorrents atIndexes: insertIndexes];
|
||||
|
||||
//redo order values
|
||||
for (NSInteger i = 0; i < [fTorrents count]; i++)
|
||||
[[fTorrents objectAtIndex: i] setOrderValue: i];
|
||||
}
|
||||
|
||||
[self applyFilter: nil];
|
||||
|
|
|
@ -69,7 +69,7 @@ typedef enum
|
|||
NSInteger fRatioSetting;
|
||||
BOOL fFinishedSeeding, fWaitToStart, fStalled;
|
||||
|
||||
NSInteger fOrderValue, fGroupValue;
|
||||
NSInteger fGroupValue;
|
||||
|
||||
BOOL fAddedTrackers;
|
||||
|
||||
|
@ -230,9 +230,6 @@ typedef enum
|
|||
- (uint64_t) failedHash;
|
||||
- (CGFloat) swarmSpeed;
|
||||
|
||||
- (NSInteger) orderValue;
|
||||
- (void) setOrderValue: (NSInteger) orderValue;
|
||||
|
||||
- (NSInteger) groupValue;
|
||||
- (void) setGroupValue: (NSInteger) groupValue;
|
||||
- (NSInteger) groupOrderValue;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
useIncompleteFolder: (NSNumber *) useIncompleteFolder incompleteFolder: (NSString *) incompleteFolder
|
||||
ratioSetting: (NSNumber *) ratioSetting ratioLimit: (NSNumber *) ratioLimit
|
||||
waitToStart: (NSNumber *) waitToStart
|
||||
orderValue: (NSNumber *) orderValue groupValue: (NSNumber *) groupValue addedTrackers: (NSNumber *) addedTrackers;
|
||||
groupValue: (NSNumber *) groupValue addedTrackers: (NSNumber *) addedTrackers;
|
||||
|
||||
- (BOOL) shouldUseIncompleteFolderForName: (NSString *) name;
|
||||
- (void) updateDownloadFolder;
|
||||
|
@ -82,7 +82,7 @@ int trashDataFile(const char * filename)
|
|||
downloadFolder: location
|
||||
useIncompleteFolder: nil incompleteFolder: nil
|
||||
ratioSetting: nil ratioLimit: nil
|
||||
waitToStart: nil orderValue: nil groupValue: nil addedTrackers: nil];
|
||||
waitToStart: nil groupValue: nil addedTrackers: nil];
|
||||
|
||||
if (self)
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ int trashDataFile(const char * filename)
|
|||
downloadFolder: location
|
||||
useIncompleteFolder: nil incompleteFolder: nil
|
||||
ratioSetting: nil ratioLimit: nil
|
||||
waitToStart: nil orderValue: nil groupValue: nil addedTrackers: nil];
|
||||
waitToStart: nil groupValue: nil addedTrackers: nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -123,7 +123,6 @@ int trashDataFile(const char * filename)
|
|||
ratioSetting: [history objectForKey: @"RatioSetting"]
|
||||
ratioLimit: [history objectForKey: @"RatioLimit"]
|
||||
waitToStart: [history objectForKey: @"WaitToStart"]
|
||||
orderValue: [history objectForKey: @"OrderValue"]
|
||||
groupValue: [history objectForKey: @"GroupValue"]
|
||||
addedTrackers: [history objectForKey: @"AddedTrackers"]];
|
||||
|
||||
|
@ -160,7 +159,6 @@ int trashDataFile(const char * filename)
|
|||
[NSNumber numberWithInt: fRatioSetting], @"RatioSetting",
|
||||
[NSNumber numberWithFloat: fRatioLimit], @"RatioLimit",
|
||||
[NSNumber numberWithBool: fWaitToStart], @"WaitToStart",
|
||||
[NSNumber numberWithInt: fOrderValue], @"OrderValue",
|
||||
[NSNumber numberWithInt: fGroupValue], @"GroupValue",
|
||||
[NSNumber numberWithBool: fAddedTrackers], @"AddedTrackers", nil];
|
||||
|
||||
|
@ -1365,16 +1363,6 @@ int trashDataFile(const char * filename)
|
|||
return fStat->swarmSpeed;
|
||||
}
|
||||
|
||||
- (NSInteger) orderValue
|
||||
{
|
||||
return fOrderValue;
|
||||
}
|
||||
|
||||
- (void) setOrderValue: (NSInteger) orderValue
|
||||
{
|
||||
fOrderValue = orderValue;
|
||||
}
|
||||
|
||||
- (NSInteger) groupValue
|
||||
{
|
||||
return fGroupValue;
|
||||
|
@ -1616,7 +1604,7 @@ int trashDataFile(const char * filename)
|
|||
useIncompleteFolder: (NSNumber *) useIncompleteFolder incompleteFolder: (NSString *) incompleteFolder
|
||||
ratioSetting: (NSNumber *) ratioSetting ratioLimit: (NSNumber *) ratioLimit
|
||||
waitToStart: (NSNumber *) waitToStart
|
||||
orderValue: (NSNumber *) orderValue groupValue: (NSNumber *) groupValue addedTrackers: (NSNumber *) addedTrackers
|
||||
groupValue: (NSNumber *) groupValue addedTrackers: (NSNumber *) addedTrackers
|
||||
{
|
||||
if (!(self = [super init]))
|
||||
return nil;
|
||||
|
@ -1707,7 +1695,6 @@ int trashDataFile(const char * filename)
|
|||
|
||||
[self createFileList];
|
||||
|
||||
fOrderValue = orderValue ? [orderValue intValue] : tr_sessionCountTorrents(lib) - 1;
|
||||
fGroupValue = groupValue ? [groupValue intValue] : [[GroupsController groups] groupIndexForTorrent: self];
|
||||
|
||||
fAddedTrackers = addedTrackers ? [addedTrackers boolValue] : NO;
|
||||
|
|
Loading…
Reference in a new issue