mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-28 05:14:34 +00:00
Phased rollout interval is an appcast item attribute and not its own element (#1385)
* phased rollout interval is an appcast item attribute and not its own element * add basic test for getting phased rollout interval from appcast item
This commit is contained in:
1 parent
99f5573619
commit
fb18c1e542
7 files changed
+20
-9
No files matched your search
Vendored
+4
-1
@@ -189,7 +189,10 @@
|
||||
self.displayVersionString = self.versionString;
|
||||
}
|
||||
|
||||
self.phasedRolloutInterval = [enclosure objectForKey:SUAppcastElementPhasedRolloutInterval];
|
||||
NSString* enclosureRolloutIntervalString = [enclosure objectForKey:SUAppcastAttributePhasedRolloutInterval];
|
||||
if(enclosureRolloutIntervalString) {
|
||||
self.phasedRolloutInterval = @(enclosureRolloutIntervalString.integerValue);
|
||||
}
|
||||
|
||||
// Find the appropriate release notes URL.
|
||||
NSString *releaseNotesString = [dict objectForKey:SUAppcastElementReleaseNotesLink];
|
||||
|
||||
Vendored
+11
-4
@@ -22,6 +22,7 @@
|
||||
#import "SUUpdateValidator.h"
|
||||
#import "SULocalizations.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SUUpdater.h"
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
|
||||
@@ -96,19 +97,25 @@
|
||||
return comparator;
|
||||
}
|
||||
|
||||
- (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem * __autoreleasing *)deltaItem
|
||||
// This method is only used for testing
|
||||
+ (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem *_Nullable __autoreleasing *_Nullable)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id<SUVersionComparison>)comparator {
|
||||
SUBasicUpdateDriver* basicUpdateDriver = [[SUBasicUpdateDriver alloc] initWithUpdater:(id<SUUpdaterPrivate>)[SUUpdater sharedUpdater]];
|
||||
return [basicUpdateDriver bestItemFromAppcastItems:appcastItems getDeltaItem:deltaItem withHostVersion:hostVersion comparator:comparator];
|
||||
}
|
||||
|
||||
- (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem * __autoreleasing *)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id<SUVersionComparison>)comparator
|
||||
{
|
||||
SUAppcastItem *item = nil;
|
||||
for(SUAppcastItem *candidate in appcastItems) {
|
||||
if ([self hostSupportsItem:candidate]) {
|
||||
if (!item || [[self versionComparator] compareVersion:item.versionString toVersion:candidate.versionString] == NSOrderedAscending) {
|
||||
if (!item || [comparator compareVersion:item.versionString toVersion:candidate.versionString] == NSOrderedAscending) {
|
||||
item = candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item && deltaItem) {
|
||||
SUAppcastItem *deltaUpdateItem = [[item deltaUpdates] objectForKey:self.host.version];
|
||||
SUAppcastItem *deltaUpdateItem = [[item deltaUpdates] objectForKey:hostVersion];
|
||||
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
|
||||
*deltaItem = deltaUpdateItem;
|
||||
}
|
||||
@@ -186,7 +193,7 @@
|
||||
{
|
||||
// Find the best supported update
|
||||
SUAppcastItem *deltaUpdateItem = nil;
|
||||
item = [self bestItemFromAppcastItems:ac.items getDeltaItem:&deltaUpdateItem];
|
||||
item = [self bestItemFromAppcastItems:ac.items getDeltaItem:&deltaUpdateItem withHostVersion:self.host.version comparator:[self versionComparator]];
|
||||
|
||||
if (item && deltaUpdateItem) {
|
||||
self.nonDeltaUpdateItem = item;
|
||||
|
||||
Vendored
+1
-1
@@ -71,6 +71,7 @@ extern NSString *const SUAppcastAttributeEDSignature;
|
||||
extern NSString *const SUAppcastAttributeShortVersionString;
|
||||
extern NSString *const SUAppcastAttributeVersion;
|
||||
extern NSString *const SUAppcastAttributeOsType;
|
||||
extern NSString *const SUAppcastAttributePhasedRolloutInterval;
|
||||
|
||||
extern NSString *const SUAppcastElementCriticalUpdate;
|
||||
extern NSString *const SUAppcastElementDeltas;
|
||||
@@ -78,7 +79,6 @@ extern NSString *const SUAppcastElementMinimumSystemVersion;
|
||||
extern NSString *const SUAppcastElementMaximumSystemVersion;
|
||||
extern NSString *const SUAppcastElementReleaseNotesLink;
|
||||
extern NSString *const SUAppcastElementTags;
|
||||
extern NSString *const SUAppcastElementPhasedRolloutInterval;
|
||||
|
||||
extern NSString *const SURSSAttributeURL;
|
||||
extern NSString *const SURSSAttributeLength;
|
||||
|
||||
Vendored
+1
-1
@@ -61,6 +61,7 @@ NSString *const SUAppcastAttributeEDSignature = @"sparkle:edSignature";
|
||||
NSString *const SUAppcastAttributeShortVersionString = @"sparkle:shortVersionString";
|
||||
NSString *const SUAppcastAttributeVersion = @"sparkle:version";
|
||||
NSString *const SUAppcastAttributeOsType = @"sparkle:os";
|
||||
NSString *const SUAppcastAttributePhasedRolloutInterval = @"sparkle:phasedRolloutInterval";
|
||||
|
||||
NSString *const SUAppcastElementCriticalUpdate = @"sparkle:criticalUpdate";
|
||||
NSString *const SUAppcastElementDeltas = @"sparkle:deltas";
|
||||
@@ -68,7 +69,6 @@ NSString *const SUAppcastElementMinimumSystemVersion = @"sparkle:minimumSystemVe
|
||||
NSString *const SUAppcastElementMaximumSystemVersion = @"sparkle:maximumSystemVersion";
|
||||
NSString *const SUAppcastElementReleaseNotesLink = @"sparkle:releaseNotesLink";
|
||||
NSString *const SUAppcastElementTags = @"sparkle:tags";
|
||||
NSString *const SUAppcastElementPhasedRolloutInterval = @"sparkle:phasedRolloutInterval";
|
||||
|
||||
NSString *const SURSSAttributeURL = @"url";
|
||||
NSString *const SURSSAttributeLength = @"length";
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<!-- The best chosen release -->
|
||||
<item>
|
||||
<title>Version 3.0</title>
|
||||
<enclosure url="http://localhost:1337/Sparkle_Test_App.zip" sparkle:version="3.0" />
|
||||
<enclosure url="http://localhost:1337/Sparkle_Test_App.zip" sparkle:version="3.0" sparkle:phasedRolloutInterval="86400" />
|
||||
<sparkle:deltas>
|
||||
<enclosure url="http://localhost:1337/3.0_from_2.0.patch"
|
||||
sparkle:version="3.0"
|
||||
|
||||
@@ -32,6 +32,7 @@ class SUAppcastTest: XCTestCase {
|
||||
XCTAssertNil(items[1].itemDescription);
|
||||
XCTAssertNil(items[1].dateString)
|
||||
XCTAssertFalse(items[1].isCriticalUpdate);
|
||||
XCTAssertEqual(items[1].phasedRolloutInterval, 86400);
|
||||
|
||||
XCTAssertEqual("Version 4.0", items[2].title);
|
||||
XCTAssertNil(items[2].itemDescription);
|
||||
|
||||
@@ -39,7 +39,7 @@ static const char *SUAppleQuarantineIdentifier = "com.apple.quarantine";
|
||||
|
||||
@interface SUBasicUpdateDriver (Private)
|
||||
|
||||
- (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem *_Nullable __autoreleasing *_Nullable)deltaItem;
|
||||
+ (SUAppcastItem *)bestItemFromAppcastItems:(NSArray *)appcastItems getDeltaItem:(SUAppcastItem *_Nullable __autoreleasing *_Nullable)deltaItem withHostVersion:(NSString *)hostVersion comparator:(id<SUVersionComparison>)comparator;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Reference in new issue
Block a user