Skip to content

Commit

Permalink
Fixing a merge error which put finish_installation in /tmp rather tha…
Browse files Browse the repository at this point in the history
…n in ~/Library/App Support
  • Loading branch information
andymatuschak committed May 10, 2011
1 parent fa67107 commit 86b6502
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
16 changes: 3 additions & 13 deletions SUBasicUpdateDriver.m
Expand Up @@ -152,24 +152,14 @@ - (void)download:(NSURLDownload *)d decideDestinationWithSuggestedFilename:(NSSt

NSString *downloadFileName = [NSString stringWithFormat:@"%@ %@", [host name], [updateItem versionString]];

NSArray *appSupportPaths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *appSupportPath = nil;
if (!appSupportPaths || [appSupportPaths count] == 0)
{
SULog(@"Failed to find app support directory! Using ~/Library/Application Support...");
appSupportPath = [@"~/Library/Application Support" stringByExpandingTildeInPath];
}
else
appSupportPath = [appSupportPaths objectAtIndex:0];
appSupportPath = [appSupportPath stringByAppendingPathComponent:[host name]];

[tempDir release];
tempDir = [[appSupportPath stringByAppendingPathComponent:downloadFileName] retain];
tempDir = [[[host appSupportPath] stringByAppendingPathComponent:downloadFileName] retain];
int cnt=1;
while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999)
{
[tempDir release];
tempDir = [[appSupportPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]] retain];
tempDir = [[[host appSupportPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d", downloadFileName, cnt++]] retain];
}

#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
Expand Down Expand Up @@ -270,7 +260,7 @@ - (void)installUpdate

// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
NSString *relaunchPathToCopy = [SPARKLE_BUNDLE pathForResource:@"finish_installation" ofType:@"app"];
NSString *targetPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
NSString *targetPath = [[host appSupportPath] stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
NSError *error = nil;
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
Expand Down
1 change: 1 addition & 0 deletions SUHost.h
Expand Up @@ -21,6 +21,7 @@
- (id)initWithBundle:(NSBundle *)aBundle;
- (NSBundle *)bundle;
- (NSString *)bundlePath;
- (NSString *)appSupportPath;
- (NSString *)installationPath;
- (NSString *)name;
- (NSString *)version;
Expand Down
15 changes: 15 additions & 0 deletions SUHost.m
Expand Up @@ -46,6 +46,21 @@ - (NSString *)bundlePath
return [bundle bundlePath];
}

- (NSString *)appSupportPath
{
NSArray *appSupportPaths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *appSupportPath = nil;
if (!appSupportPaths || [appSupportPaths count] == 0)
{
SULog(@"Failed to find app support directory! Using ~/Library/Application Support...");
appSupportPath = [@"~/Library/Application Support" stringByExpandingTildeInPath];
}
else
appSupportPath = [appSupportPaths objectAtIndex:0];
appSupportPath = [appSupportPath stringByAppendingPathComponent:[self name]];
return appSupportPath;
}

- (NSString *)installationPath
{
#if NORMALIZE_INSTALLED_APP_NAME
Expand Down

0 comments on commit 86b6502

Please sign in to comment.