From bc0e338cde523c1140443e362691f1c4fc3cd6d5 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 24 Jan 2021 20:17:10 -0800 Subject: [PATCH] Use new update group for next downloaded update if applicable --- Sparkle/SPUCoreBasedUpdateDriver.h | 2 ++ Sparkle/SPUCoreBasedUpdateDriver.m | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/Sparkle/SPUCoreBasedUpdateDriver.h b/Sparkle/SPUCoreBasedUpdateDriver.h index 9014289d..d727d33c 100644 --- a/Sparkle/SPUCoreBasedUpdateDriver.h +++ b/Sparkle/SPUCoreBasedUpdateDriver.h @@ -35,6 +35,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)downloadDriverDidReceiveDataOfLength:(uint64_t)length; +- (void)downloadDriverDidDownloadUpdate; + - (void)coreDriverDidStartExtractingUpdate; - (void)installerDidStartInstalling; diff --git a/Sparkle/SPUCoreBasedUpdateDriver.m b/Sparkle/SPUCoreBasedUpdateDriver.m index d1647ce4..66d2565c 100644 --- a/Sparkle/SPUCoreBasedUpdateDriver.m +++ b/Sparkle/SPUCoreBasedUpdateDriver.m @@ -20,6 +20,7 @@ #import "SUAppcastItem.h" #import "SULocalizations.h" #import "SPUInstallationType.h" +#import "SUPhasedUpdateGroupInfo.h" #include "AppKitPrevention.h" @@ -40,6 +41,7 @@ @property (nonatomic, readonly, weak) id updater; // if we didn't have legacy support, I'd remove this.. @property (nullable, nonatomic, readonly, weak) id updaterDelegate; @property (nonatomic) NSString *userAgent; +@property (nonatomic) BOOL downloadInBackground; @end @@ -58,6 +60,7 @@ @synthesize updaterDelegate = _updaterDelegate; @synthesize userAgent = _userAgent; @synthesize resumableUpdate = _resumableUpdate; +@synthesize downloadInBackground = _downloadInBackground; - (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id )updaterDelegate delegate:(id)delegate { @@ -166,6 +169,8 @@ - (void)downloadUpdateFromAppcastItem:(SUAppcastItem *)updateItem inBackground:(BOOL)background { + self.downloadInBackground = background; + self.downloadDriver = [[SPUDownloadDriver alloc] initWithUpdateItem:updateItem host:self.host userAgent:self.userAgent inBackground:background delegate:self]; if ([self.updaterDelegate respondsToSelector:@selector((updater:willDownloadUpdate:withRequest:))]) { @@ -200,6 +205,11 @@ - (void)downloadDriverDidDownloadUpdate:(SPUDownloadedUpdate *)downloadedUpdate { + // Use a new update group for our next downloaded update, if applicable + if (self.downloadInBackground && downloadedUpdate.updateItem.phasedRolloutInterval != nil) { + [SUPhasedUpdateGroupInfo setNewUpdateGroupIdentifierForHost:self.host]; + } + self.resumableUpdate = downloadedUpdate; [self extractUpdate:downloadedUpdate]; }