diff --git a/Sparkle/SUAppcastDriver.m b/Sparkle/SUAppcastDriver.m index 6770f8a5..a11c9df3 100644 --- a/Sparkle/SUAppcastDriver.m +++ b/Sparkle/SUAppcastDriver.m @@ -117,8 +117,10 @@ // This method is used by unit tests + (SUAppcast *)filterSupportedAppcast:(SUAppcast *)appcast phasedUpdateGroup:(NSNumber * _Nullable)phasedUpdateGroup { + NSDate *currentDate = [NSDate date]; + return [appcast copyByFilteringItems:^(SUAppcastItem *item) { - return (BOOL)([[self class] itemOperatingSystemIsOK:item] && [[self class] itemIsReadyForPhasedRollout:item phasedUpdateGroup:phasedUpdateGroup]); + return (BOOL)([[self class] itemOperatingSystemIsOK:item] && [[self class] itemIsReadyForPhasedRollout:item phasedUpdateGroup:phasedUpdateGroup currentDate:currentDate]); }]; } @@ -202,7 +204,7 @@ return [[self versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending; } -+ (BOOL)itemIsReadyForPhasedRollout:(SUAppcastItem *)ui phasedUpdateGroup:(NSNumber * _Nullable)phasedUpdateGroup ++ (BOOL)itemIsReadyForPhasedRollout:(SUAppcastItem *)ui phasedUpdateGroup:(NSNumber * _Nullable)phasedUpdateGroup currentDate:(NSDate *)currentDate { if (phasedUpdateGroup == nil || [ui isCriticalUpdate]) { return YES; @@ -218,7 +220,7 @@ return YES; } - NSTimeInterval timeSinceRelease = [[NSDate date] timeIntervalSinceDate:itemReleaseDate]; + NSTimeInterval timeSinceRelease = [currentDate timeIntervalSinceDate:itemReleaseDate]; NSTimeInterval phasedRolloutInterval = [phasedRolloutIntervalObject doubleValue]; NSTimeInterval timeToWaitForGroup = phasedRolloutInterval * phasedUpdateGroup.unsignedIntegerValue;