From 29d4b801fce052a101a674ea46188dc96ec23e5b Mon Sep 17 00:00:00 2001 From: Mayur Pawashe Date: Sat, 10 Jul 2021 08:52:33 -0700 Subject: [PATCH] Reset skipped updates when updates are user initiated and checked (#1887) Instead of only when a new update is found. This resets skipped updates if the user initiates a new check even if a new update is not found. --- Sparkle/SPUUIBasedUpdateDriver.m | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Sparkle/SPUUIBasedUpdateDriver.m b/Sparkle/SPUUIBasedUpdateDriver.m index 7f6ad5fd..45369c84 100644 --- a/Sparkle/SPUUIBasedUpdateDriver.m +++ b/Sparkle/SPUUIBasedUpdateDriver.m @@ -139,22 +139,35 @@ [self.coreDriver preflightForUpdatePermissionPreventingInstallerInteraction:preventsInstallerInteraction reply:reply]; } +- (void)_clearSkippedUpdatesIfUserInitiated +{ + if (self.userInitiated) { + [SPUSkippedUpdate clearSkippedUpdateForHost:self.host]; + } +} + - (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background { self.httpHeaders = httpHeaders; self.userAgent = userAgent; + [self _clearSkippedUpdatesIfUserInitiated]; + [self.coreDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:background requiresSilentInstall:NO]; } - (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock { + [self _clearSkippedUpdatesIfUserInitiated]; + self.resumingInstallingUpdate = YES; [self.coreDriver resumeInstallingUpdateWithCompletion:completionBlock]; } - (void)resumeUpdate:(id)resumableUpdate completion:(SPUUpdateDriverCompletion)completionBlock { + [self _clearSkippedUpdatesIfUserInitiated]; + // Informational downloads shouldn't be presented as updates to be downloaded // Neither should items that prevent auto updating if (!resumableUpdate.updateItem.isInformationOnlyUpdate && !resumableUpdate.updateItem.majorUpgrade) { @@ -172,10 +185,6 @@ - (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem * _Nullable)secondaryUpdateItem { - if (self.userInitiated) { - [SPUSkippedUpdate clearSkippedUpdateForHost:self.host]; - } - id updaterDelegate = self.updaterDelegate; SPUUserUpdateStage stage;