Skip to content

Commit

Permalink
Fix enclosure download when the URL contains a query
Browse files Browse the repository at this point in the history
  • Loading branch information
barijaona committed Oct 25, 2015
1 parent 4cf05e7 commit 29d4aa9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/AppController.m
Expand Up @@ -1363,9 +1363,7 @@ -(IBAction)downloadEnclosure:(id)sender
{
if ([currentArticle hasEnclosure])
{
NSString * filename = [[currentArticle enclosure] lastPathComponent];
NSString * destPath = [DownloadManager fullDownloadPath:filename];
[[DownloadManager sharedInstance] downloadFile:destPath fromURL:[currentArticle enclosure]];
[[DownloadManager sharedInstance] downloadFileFromURL:[currentArticle enclosure]];
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/DownloadManager.h
Expand Up @@ -68,5 +68,5 @@
-(void)clearList;
-(void)cancelItem:(DownloadItem *)item;
-(void)removeItem:(DownloadItem *)item;
-(void)downloadFile:(NSString *)filename fromURL:(NSString *)url;
-(void)downloadFileFromURL:(NSString *)url;
@end
6 changes: 4 additions & 2 deletions src/DownloadManager.m
Expand Up @@ -319,8 +319,10 @@ -(void)cancelItem:(DownloadItem *)item
/* downloadFile
* Downloads a file from the specified URL.
*/
-(void)downloadFile:(NSString *)filename fromURL:(NSString *)url
-(void)downloadFileFromURL:(NSString *)url
{
NSString * filename = [[NSURL URLWithString:url] lastPathComponent];
NSString * destPath = [DownloadManager fullDownloadPath:filename];
NSURLRequest * theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSURLDownload * theDownload = [[NSURLDownload alloc] initWithRequest:theRequest delegate:(id)self];
if (theDownload)
Expand All @@ -332,7 +334,7 @@ -(void)downloadFile:(NSString *)filename fromURL:(NSString *)url
[downloadsList addObject:newItem];

// The following line will stop us getting decideDestinationWithSuggestedFilename.
[theDownload setDestination:filename allowOverwrite:YES];
[theDownload setDestination:destPath allowOverwrite:YES];

}
}
Expand Down
7 changes: 2 additions & 5 deletions src/StdEnclosureView.m
Expand Up @@ -77,7 +77,7 @@ -(void)setEnclosureFile:(NSString *)newFilename
// Keep this for the download/open
enclosureFilename = newFilename;

NSString * basename = [enclosureFilename lastPathComponent];
NSString * basename = [[NSURL URLWithString:enclosureFilename] lastPathComponent];
NSString * encodedname = [basename stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString * ext = [encodedname pathExtension];

Expand Down Expand Up @@ -138,10 +138,7 @@ -(void)setEnclosureFile:(NSString *)newFilename
*/
-(IBAction)downloadFile:(id)sender
{
NSString * theFilename = [enclosureFilename lastPathComponent];
NSString * destPath = [DownloadManager fullDownloadPath:theFilename];

[[DownloadManager sharedInstance] downloadFile:destPath fromURL:enclosureFilename];
[[DownloadManager sharedInstance] downloadFileFromURL:enclosureFilename];
}

/* openFile
Expand Down

0 comments on commit 29d4aa9

Please sign in to comment.