Store location after it's set, incase the name isn't exactly what it was set to.

This commit is contained in:
Mitchell Livingston 2006-11-13 14:45:28 +00:00
parent c97aa2b55a
commit 96006d2d18
1 changed files with 13 additions and 8 deletions

View File

@ -499,13 +499,15 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[download release];
}
else
[download setDestination: [NSTemporaryDirectory() stringByAppendingPathComponent: [suggestedName lastPathComponent]]
allowOverwrite: NO];
}
-(void) download: (NSURLDownload *) download didCreateDestination: (NSString *) path
{
NSString * path = [NSTemporaryDirectory() stringByAppendingPathComponent: [suggestedName lastPathComponent]];
[download setDestination: path allowOverwrite: NO];
[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