merge the group location selection code

This commit is contained in:
Mitchell Livingston 2008-12-13 22:49:46 +00:00
parent 359e462091
commit 29863264e5
3 changed files with 15 additions and 13 deletions

View File

@ -67,11 +67,6 @@
fDeleteEnable = deleteTorrent == TORRENT_FILE_DEFAULT;
fGroupValue = [torrent groupValue];
#warning factor in if there already is a destination
// set the groups download location if there is one
if (!fLockDestination && [[GroupsController groups] usesCustomDownloadLocationForIndex: fGroupValue])
[self setDestinationPath: [[GroupsController groups] customDownloadLocationForIndex: fGroupValue]];
}
return self;
}

View File

@ -823,8 +823,12 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
//determine download location
NSString * location;
BOOL lockDestination = NO; //don't override the location with a group location if it has a hardcoded path
if (path)
{
location = [path stringByExpandingTildeInPath];
lockDestination = YES;
}
else if ([fDefaults boolForKey: @"DownloadLocationConstant"])
location = [[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath];
else if (type != ADD_URL)
@ -842,13 +846,17 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
deleteTorrentFile: showWindow ? TORRENT_FILE_SAVE : deleteTorrentFile lib: fLib]))
continue;
//change the location if the group calls for it (this has to wait until after the torrent is create)
if (!lockDestination && [[GroupsController groups] usesCustomDownloadLocationForIndex: [torrent groupValue]])
{
location = [[GroupsController groups] customDownloadLocationForIndex: [torrent groupValue]];
[torrent changeDownloadFolder: location];
}
//verify the data right away if it was newly created
if (type == ADD_CREATED)
[torrent resetCache];
//don't override the location with a group location if it was a created torrent
BOOL lockDestination = location && type == ADD_CREATED;
//add it to the "File -> Open Recent" menu
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
@ -863,10 +871,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
{
[torrent setWaitToStart: [fDefaults boolForKey: @"AutoStartDownload"]];
#warning move into torrent init?
if (!lockDestination && [[GroupsController groups] usesCustomDownloadLocationForIndex: [torrent groupValue]])
[torrent changeDownloadFolder: [[GroupsController groups] customDownloadLocationForIndex: [torrent groupValue]]];
[torrent update];
[fTorrents addObject: torrent];
[torrent release];

View File

@ -170,8 +170,11 @@ GroupsController * fGroupsInstance = nil;
- (BOOL) usesCustomDownloadLocationForIndex: (NSInteger) index
{
if (![self customDownloadLocationForIndex: index])
return NO;
NSInteger orderIndex = [self rowValueForIndex: index];
return orderIndex != -1 ? [[[fGroups objectAtIndex: orderIndex] objectForKey: @"UsesCustomDownloadLocation"] boolValue] : NO;
return [[[fGroups objectAtIndex: orderIndex] objectForKey: @"UsesCustomDownloadLocation"] boolValue];
}
- (void) setUsesCustomDownloadLocation: (BOOL) useCustomLocation forIndex: (NSInteger) index