From 64d740a761704a2d943f7f645bf9974a44d0bd0a Mon Sep 17 00:00:00 2001 From: Zorg Date: Wed, 13 Jul 2016 22:55:20 -0400 Subject: [PATCH] Don't log SMJobRemove() job not found error Also rationalize why we aren't first checking if the job already exists --- InstallerLauncher/SUInstallerLauncher.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/InstallerLauncher/SUInstallerLauncher.m b/InstallerLauncher/SUInstallerLauncher.m index 16dc43f3..6c1d2ddd 100644 --- a/InstallerLauncher/SUInstallerLauncher.m +++ b/InstallerLauncher/SUInstallerLauncher.m @@ -45,10 +45,16 @@ CFStringRef domain = (grantsSystemPrivilege ? kSMDomainSystemLaunchd : kSMDomainUserLaunchd); NSString *label = [NSString stringWithFormat:@"%@-sparkle-updater", hostBundleIdentifier]; + // Try to remove the job from launchd if it is already running + // We could invoke SMJobCopyDictionary() first to see if the job exists, but I'd rather avoid + // using it because the headers indicate it may be removed one day without any replacement CFErrorRef removeError = NULL; if (!SMJobRemove(domain, (__bridge CFStringRef)(label), auth, true, &removeError)) { if (removeError != NULL) { - SULog(@"Remove error: %@", removeError); + // It's normal for a job to not be found, so this is not an interesting error + if (CFErrorGetCode(removeError) != kSMErrorJobNotFound) { + SULog(@"Remove error: %@", removeError); + } CFRelease(removeError); } }