Skip to content

Commit

Permalink
Merge pull request #602 from pjrobertson/latestDownloadFixes
Browse files Browse the repository at this point in the history
Small fixes to the latest download proxy
  • Loading branch information
skurfer committed Jan 4, 2012
2 parents bdf64c8 + af1798f commit 66d7c98
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions Quicksilver/Code-QuickStepCore/QSDownloads.m
Expand Up @@ -12,23 +12,30 @@

@implementation QSDownloads
- (id)resolveProxyObject:(id)proxy {
NSString *downloads = [@"~/Downloads" stringByStandardizingPath];
NSString *downloads = [[@"~/Downloads" stringByExpandingTildeInPath] stringByResolvingSymlinksInPath];
NSFileManager *manager = [[NSFileManager alloc] init];
NSString *downloadPath, *mrdpath;
NSDate *modified = nil;
NSDate *mostRecent = [NSDate distantPast];

NSNumber *isDir;
NSNumber *isPackage;
NSURL *downloadsURL = [NSURL URLWithString:downloads];
NSError *err = nil;
// An array of the directory contents, keeping the isDirectory key, attributeModificationDate key and skipping hidden files
NSArray *contents = [manager contentsOfDirectoryAtURL:downloadsURL
includingPropertiesForKeys:[NSArray arrayWithObjects:NSURLIsDirectoryKey,NSURLAttributeModificationDateKey,nil]
options:NSDirectoryEnumerationSkipsHiddenFiles
error:nil];
error:&err];
if (err) {
NSLog(@"Error resolving downloads path: %@", err);
return nil;
}

NSString *downloadPath = nil;
NSString *mrdpath = nil;
NSDate *modified = nil;
NSDate *mostRecent = [NSDate distantPast];

NSNumber *isDir;
NSNumber *isPackage;
for (NSURL *downloadedFile in contents) {
NSError *err = nil;

err = nil;
NSString *fileExtension = [downloadedFile pathExtension];
if ([fileExtension isEqualToString:@"download"] ||
[fileExtension isEqualToString:@"part"] ||
Expand Down Expand Up @@ -67,6 +74,11 @@ - (id)resolveProxyObject:(id)proxy {
}
}
[manager release];
return [QSObject fileObjectWithPath:mrdpath];
if (mrdpath) {
return [QSObject fileObjectWithPath:mrdpath];
}
else {
return nil;
}
}
@end

0 comments on commit 66d7c98

Please sign in to comment.