mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-28 05:14:34 +00:00
Combine phasedUpdateGroup / background flags
This commit is contained in:
1 parent
044313db59
commit
6c846d0fad
3 files changed
+9
-8
No files matched your search
Vendored
+7
-6
@@ -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;
|
||||
|
||||
@@ -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!
|
||||
|
||||
|
||||
@@ -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<SUVersionComparison>)comparator;
|
||||
|
||||
+ (SUAppcast *)filterSupportedAppcast:(SUAppcast *)appcast phasedUpdateGroup:(NSUInteger)phasedUpdateGroup inBackground:(BOOL)background;
|
||||
+ (SUAppcast *)filterSupportedAppcast:(SUAppcast *)appcast phasedUpdateGroup:(NSNumber * _Nullable)phasedUpdateGroup;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Reference in new issue
Block a user