From 96006d2d1827be0a0cf99988ce797707ebefcac2 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Mon, 13 Nov 2006 14:45:28 +0000 Subject: [PATCH] Store location after it's set, incase the name isn't exactly what it was set to. --- macosx/Controller.m | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index 6a2f83156..16788bc6e 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -499,12 +499,14 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [download release]; } else - { - NSString * path = [NSTemporaryDirectory() stringByAppendingPathComponent: [suggestedName lastPathComponent]]; - [download setDestination: path allowOverwrite: NO]; - [fPendingTorrentDownloads setObject: [NSDictionary dictionaryWithObjectsAndKeys: + [download setDestination: [NSTemporaryDirectory() stringByAppendingPathComponent: [suggestedName lastPathComponent]] + allowOverwrite: NO]; +} + +-(void) download: (NSURLDownload *) download didCreateDestination: (NSString *) path +{ + [fPendingTorrentDownloads setObject: [NSDictionary dictionaryWithObjectsAndKeys: path, @"Path", download, @"Download", nil] forKey: [[download request] URL]]; - } } - (void) download: (NSURLDownload *) download didFailWithError: (NSError *) error @@ -521,12 +523,15 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy - (void) downloadDidFinish: (NSURLDownload *) download { - #warning try to open, if not delete - [self openFiles: [NSArray arrayWithObject: [[fPendingTorrentDownloads objectForKey: - [[download request] URL]] objectForKey: @"Path"]] ignoreDownloadFolder: NO forceDeleteTorrent: YES]; + NSString * path = [[fPendingTorrentDownloads objectForKey: [[download request] URL]] objectForKey: @"Path"]; + + [self openFiles: [NSArray arrayWithObject: path] ignoreDownloadFolder: NO forceDeleteTorrent: YES]; [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]]; [download release]; + + //delete torrent file if it wasn't already + [[NSFileManager defaultManager] removeFileAtPath: path handler: nil]; } - (void) application: (NSApplication *) sender openFiles: (NSArray *) filenames