Compute current date only once for all app cast items

This commit is contained in:
Zorg committed 2021-01-30 18:09:39 -08:00
1 parent 6c846d0fad
commit e8ebf23504
1 file changed
+5 -3
+5 -3
View File
@@ -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;