Actually works now, but leaves one leftover copy of relaunch in NSTemporaryDirectory()

This commit is contained in:
David Smith committed 2008-05-14 22:48:19 -07:00
1 parent c722b09ba6
commit f1198d8167
2 files changed
+2 -10

No files matched your search

-10
View File
@@ -185,16 +185,6 @@
realRelauncherPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"relaunch" ofType:@""];
[NSTask launchedTaskWithLaunchPath:realRelauncherPath arguments:[NSArray arrayWithObjects:[hostBundle bundlePath], [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], nil]];
//if there's a possibility that a copy of relauncher is in NSTemporaryDirectory(), we need to be sure to clean it up
if(relaunchPath)
{
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation
source:[relaunchPath stringByDeletingLastPathComponent]
destination:@""
files:[NSArray arrayWithObject:[relaunchPath lastPathComponent]]
tag:NULL];
}
}
@catch (NSException *e)
{
+2
View File
@@ -58,6 +58,8 @@ NSString *SUInstallerDelegateKey = @"SUInstallerDelegate";
{
NSString *relaunchPathToCopy = [[NSBundle bundleForClass:[self class]] pathForResource:@"relaunch" ofType:@""];
NSString *targetPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
//Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems
[[NSFileManager defaultManager] removeFileAtPath:targetPath handler:nil];
if([[NSFileManager defaultManager] copyPath:relaunchPathToCopy toPath:targetPath handler:nil])
*relaunchPath = targetPath;