From 66a11b83f0e6654f2ffc7c3d3792eb49f1b72e62 Mon Sep 17 00:00:00 2001 From: Zorg Date: Thu, 24 Sep 2015 23:07:49 -0400 Subject: [PATCH 1/3] Don't install automatic updates if the system might shut off --- Sparkle/SUAutomaticUpdateDriver.m | 11 +++++++++++ Sparkle/SUErrors.h | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Sparkle/SUAutomaticUpdateDriver.m b/Sparkle/SUAutomaticUpdateDriver.m index 45b3d546..562f2d05 100644 --- a/Sparkle/SUAutomaticUpdateDriver.m +++ b/Sparkle/SUAutomaticUpdateDriver.m @@ -63,6 +63,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 - (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil]; // Sudden termination is available on 10.6+ NSProcessInfo *processInfo = [NSProcessInfo processInfo]; @@ -103,6 +104,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 if (self.willUpdateOnTermination) { [[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillTerminateNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self name:NSWorkspaceWillPowerOffNotification object:nil]; + NSProcessInfo *processInfo = [NSProcessInfo processInfo]; [processInfo enableSuddenTermination]; @@ -151,6 +154,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 case SUInstallLaterChoice: self.postponingInstallation = YES; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil]; // We're already waiting on quit, just indicate that we're idle. self.interruptible = YES; break; @@ -172,6 +176,13 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 [super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI]; } +- (void)systemWillPowerOff:(NSNotification *)__unused note +{ + [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSystemPowerOffError userInfo:@{ + NSLocalizedDescriptionKey: SULocalizedString(@"The update will not be installed because the user requested for the system to power off", nil) + }]]; +} + - (void)applicationWillTerminate:(NSNotification *)__unused note { [self installWithToolAndRelaunch:NO]; diff --git a/Sparkle/SUErrors.h b/Sparkle/SUErrors.h index e624bb05..d73aadba 100644 --- a/Sparkle/SUErrors.h +++ b/Sparkle/SUErrors.h @@ -38,7 +38,10 @@ typedef NS_ENUM(OSStatus, SUError) { SUMissingInstallerToolError = 4003, SURelaunchError = 4004, SUInstallationError = 4005, - SUDowngradeError = 4006 + SUDowngradeError = 4006, + + // System phase errors + SUSystemPowerOffError = 5000 }; #endif From 72618a0d3a497c148826c8da3e45e84674e85e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Mon, 9 Nov 2015 00:33:29 +0000 Subject: [PATCH 2/3] 1.11.1 --- CHANGELOG | 4 ++++ Configurations/ConfigCommon.xcconfig | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 97b5f3be..cd0be2ff 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +# 1.11.1 + +* Don't install automatic updates when system is about to shut down + # 1.11.0 * Big improvements to code signing and DSA verification diff --git a/Configurations/ConfigCommon.xcconfig b/Configurations/ConfigCommon.xcconfig index d9e78800..580edc56 100644 --- a/Configurations/ConfigCommon.xcconfig +++ b/Configurations/ConfigCommon.xcconfig @@ -16,7 +16,7 @@ SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0 SPARKLE_VERSION_MAJOR = 1 SPARKLE_VERSION_MINOR = 11 -SPARKLE_VERSION_PATCH = 0 +SPARKLE_VERSION_PATCH = 1 SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH) CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION) From 4022b01041abe92384923fc600c927ac4743a0ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Fri, 13 Nov 2015 19:15:26 +0000 Subject: [PATCH 3/3] Updated podspec --- Sparkle.podspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sparkle.podspec b/Sparkle.podspec index e4aaf773..8ea9278d 100644 --- a/Sparkle.podspec +++ b/Sparkle.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Sparkle" - s.version = "1.11.0" + s.version = "1.11.1" s.summary = "A software update framework for OS X" s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers." s.homepage = "http://sparkle-project.org" @@ -13,6 +13,7 @@ Pod::Spec.new do |s| 'Kornel LesiƄski' => 'pornel@pornel.net', 'C.W. Betts' => 'computers57@hotmail.com', 'Jake Petroules' => 'jake.petroules@petroules.com', + 'Mayur Pawashe' => 'zorgiepoo@gmail.com', } s.platform = :osx, '10.7'