improved updater logic

This commit is contained in:
Patrick Wardle 2021-05-07 23:45:56 -04:00
parent 7a7d8f20ea
commit 9a6ee5811f
2 changed files with 24 additions and 8 deletions

View File

@ -395,10 +395,6 @@ bail:
//init app dest
applicationDest = [@"/Applications" stringByAppendingPathComponent:APP_NAME];
//remove xattrs
// otherwise app translocation may causes issues
execTask(XATTR, @[@"-rc", applicationDest], YES, NO);
//copy
if(YES != [NSFileManager.defaultManager copyItemAtPath:applicationSrc toPath:applicationDest error:&error])
{
@ -412,6 +408,13 @@ bail:
//dbg msg
os_log_debug(logHandle, "copied %{public}@ -> %{public}@", applicationSrc, applicationDest);
//remove xattrs
// otherwise app translocation may causes issues
execTask(XATTR, @[@"-rc", applicationDest], YES, NO);
//dbg msg
os_log_debug(logHandle, "removed %{public}@'s xattrs", applicationDest);
//happy
wasInstalled = YES;

View File

@ -138,6 +138,12 @@ extern os_log_t logHandle;
{
//action
NSInteger action = 0;
//app path
NSURL* appPath = nil;
//error
NSError* error = nil;
//grab tag
action = ((NSButton*)sender).tag;
@ -206,11 +212,18 @@ extern os_log_t logHandle;
// launch helper/login item
if(YES == self.supportView.window.isVisible)
{
//dbg msg
os_log_debug(logHandle, "now launching: %@", APP_NAME);
//init app path
appPath = [NSURL fileURLWithPath:[@"/Applications" stringByAppendingPathComponent:APP_NAME]];
//launch helper app
execTask(OPEN, @[[@"/Applications" stringByAppendingPathComponent:APP_NAME], @"--args", INITIAL_LAUNCH], NO, NO);
//dbg msg
os_log_debug(logHandle, "now launching: %{public}@", appPath);
//launch it
if(nil == [[NSWorkspace sharedWorkspace] launchApplicationAtURL:appPath options:0 configuration:@{NSWorkspaceLaunchConfigurationArguments:@[INITIAL_LAUNCH]} error:&error])
{
//err msg
os_log_error(logHandle, "ERROR: failed to launch %{public}@ (error: %{public}@)", appPath, error);
}
}
//close window