diff --git a/Sparkle/SUAppcastDriver.m b/Sparkle/SUAppcastDriver.m index 5f1b0e31..6770f8a5 100644 --- a/Sparkle/SUAppcastDriver.m +++ b/Sparkle/SUAppcastDriver.m @@ -75,7 +75,8 @@ NSDictionary *userInfo = @{ SUUpdaterAppcastNotificationKey: loadedAppcast }; [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:self.updater userInfo:userInfo]; - SUAppcast *supportedAppcast = [[self class] filterSupportedAppcast:loadedAppcast phasedUpdateGroup:[SUPhasedUpdateGroupInfo updateGroupForHost:self.host] inBackground:background]; + NSNumber *phasedUpdateGroup = background ? @([SUPhasedUpdateGroupInfo updateGroupForHost:self.host]) : nil; + SUAppcast *supportedAppcast = [[self class] filterSupportedAppcast:loadedAppcast phasedUpdateGroup:phasedUpdateGroup]; SUAppcastItem *item = nil; SUAppcastItem *nonDeltaUpdateItem = nil; @@ -114,10 +115,10 @@ } // This method is used by unit tests -+ (SUAppcast *)filterSupportedAppcast:(SUAppcast *)appcast phasedUpdateGroup:(NSUInteger)phasedUpdateGroup inBackground:(BOOL)background ++ (SUAppcast *)filterSupportedAppcast:(SUAppcast *)appcast phasedUpdateGroup:(NSNumber * _Nullable)phasedUpdateGroup { return [appcast copyByFilteringItems:^(SUAppcastItem *item) { - return (BOOL)([[self class] itemOperatingSystemIsOK:item] && [[self class] itemIsReadyForPhasedRollout:item phasedUpdateGroup:phasedUpdateGroup inBackground:background]); + return (BOOL)([[self class] itemOperatingSystemIsOK:item] && [[self class] itemIsReadyForPhasedRollout:item phasedUpdateGroup:phasedUpdateGroup]); }]; } @@ -201,9 +202,9 @@ return [[self versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending; } -+ (BOOL)itemIsReadyForPhasedRollout:(SUAppcastItem *)ui phasedUpdateGroup:(NSUInteger)phasedUpdateGroup inBackground:(BOOL)background ++ (BOOL)itemIsReadyForPhasedRollout:(SUAppcastItem *)ui phasedUpdateGroup:(NSNumber * _Nullable)phasedUpdateGroup { - if (!background || [ui isCriticalUpdate]) { + if (phasedUpdateGroup == nil || [ui isCriticalUpdate]) { return YES; } @@ -220,7 +221,7 @@ NSTimeInterval timeSinceRelease = [[NSDate date] timeIntervalSinceDate:itemReleaseDate]; NSTimeInterval phasedRolloutInterval = [phasedRolloutIntervalObject doubleValue]; - NSTimeInterval timeToWaitForGroup = phasedRolloutInterval * phasedUpdateGroup; + NSTimeInterval timeToWaitForGroup = phasedRolloutInterval * phasedUpdateGroup.unsignedIntegerValue; if (timeSinceRelease >= timeToWaitForGroup) { return YES; diff --git a/Tests/SUAppcastTest.swift b/Tests/SUAppcastTest.swift index 5c2adac9..9078af35 100644 --- a/Tests/SUAppcastTest.swift +++ b/Tests/SUAppcastTest.swift @@ -44,7 +44,7 @@ class SUAppcastTest: XCTestCase { XCTAssertFalse(items[3].isCriticalUpdate) // Test best appcast item & a delta update item - let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: 0, inBackground: false) + let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil) let supportedAppcastItems = supportedAppcast.items! diff --git a/Tests/Sparkle Unit Tests-Bridging-Header.h b/Tests/Sparkle Unit Tests-Bridging-Header.h index eff5e53a..3d588558 100644 --- a/Tests/Sparkle Unit Tests-Bridging-Header.h +++ b/Tests/Sparkle Unit Tests-Bridging-Header.h @@ -36,7 +36,7 @@ static const char *SUAppleQuarantineIdentifier = "com.apple.quarantine"; + (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem *_Nullable __autoreleasing *_Nullable)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id)comparator; -+ (SUAppcast *)filterSupportedAppcast:(SUAppcast *)appcast phasedUpdateGroup:(NSUInteger)phasedUpdateGroup inBackground:(BOOL)background; ++ (SUAppcast *)filterSupportedAppcast:(SUAppcast *)appcast phasedUpdateGroup:(NSNumber * _Nullable)phasedUpdateGroup; @end