mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Merge pull request #1849 from sparkle-project/appcast-item-nullability
Add nullability annotations to SUAppcastItem
This commit is contained in:
10 files changed
+120
-69
No files matched your search
@@ -22,14 +22,14 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
* signatures - signatures for the update that came from the appcast item
|
||||
* decryptionPassword - optional decryption password for dmg archives
|
||||
*/
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName installationType:(NSString *)installationType signatures:(SUSignatures *)signatures decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName installationType:(NSString *)installationType signatures:(SUSignatures * _Nullable)signatures decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *relaunchPath;
|
||||
@property (nonatomic, copy, readonly) NSString *hostBundlePath;
|
||||
@property (nonatomic, copy, readonly) NSString *updateDirectoryPath;
|
||||
@property (nonatomic, copy, readonly) NSString *downloadName;
|
||||
@property (nonatomic, copy, readonly) NSString *installationType;
|
||||
@property (nonatomic, strong, readonly) SUSignatures *signatures;
|
||||
@property (nonatomic, readonly, nullable) SUSignatures *signatures; // nullable because although not using signatures is deprecated, it's still supported
|
||||
@property (nonatomic, copy, readonly, nullable) NSString *decryptionPassword;
|
||||
|
||||
@end
|
||||
|
||||
@@ -30,7 +30,7 @@ static NSString *SUInstallationTypeKey = @"SUInstallationType";
|
||||
@synthesize decryptionPassword = _decryptionPassword;
|
||||
@synthesize installationType = _installationType;
|
||||
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName installationType:(NSString *)installationType signatures:(SUSignatures *)signatures decryptionPassword:(nullable NSString *)decryptionPassword
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName installationType:(NSString *)installationType signatures:(SUSignatures * _Nullable)signatures decryptionPassword:(nullable NSString *)decryptionPassword
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
|
||||
Vendored
+4
-1
@@ -137,7 +137,10 @@
|
||||
|
||||
- (instancetype)initWithUpdateItem:(SUAppcastItem *)updateItem secondaryUpdateItem:(SUAppcastItem * _Nullable)secondaryUpdateItem host:(SUHost *)host userAgent:(NSString * _Nullable)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background delegate:(id<SPUDownloadDriverDelegate>)delegate
|
||||
{
|
||||
self = [self initWithRequestURL:updateItem.fileURL host:host userAgent:userAgent httpHeaders:httpHeaders inBackground:background delegate:delegate];
|
||||
NSURL *updateFileURL = updateItem.fileURL;
|
||||
assert(updateFileURL != nil);
|
||||
|
||||
self = [self initWithRequestURL:updateFileURL host:host userAgent:userAgent httpHeaders:httpHeaders inBackground:background delegate:delegate];
|
||||
if (self != nil) {
|
||||
_updateItem = updateItem;
|
||||
_secondaryUpdateItem = secondaryUpdateItem;
|
||||
|
||||
Vendored
+1
-1
@@ -14,6 +14,6 @@
|
||||
#define SPUInstallationTypeInteractivePackage @"interactive-package" // the deprecated installation type; use guided package instead
|
||||
|
||||
#define SPUInstallationTypesArray (@[SPUInstallationTypeApplication, SPUInstallationTypeGuidedPackage, SPUInstallationTypeInteractivePackage])
|
||||
#define SPUValidInstallationType(x) ((x != nil) && [SPUInstallationTypesArray containsObject:x])
|
||||
#define SPUValidInstallationType(x) ((x != nil) && [SPUInstallationTypesArray containsObject:(NSString * _Nonnull)x])
|
||||
|
||||
#endif /* SPUInstallationType_h */
|
||||
Vendored
+17
-10
@@ -166,7 +166,8 @@
|
||||
if ([self itemContainsValidUpdate:primaryItem inBackground:background includesSkippedUpdates:includesSkippedUpdates]) {
|
||||
[self.delegate didFindValidUpdateWithAppcastItem:primaryItem secondaryAppcastItem:secondaryItem preventsAutoupdate:[self itemPreventsAutoupdate:primaryItem]];
|
||||
} else {
|
||||
NSComparisonResult hostToLatestAppcastItemComparisonResult = (primaryItem != nil) ? [[self versionComparator] compareVersion:[self.host version] toVersion:[primaryItem versionString]] : 0;
|
||||
NSComparisonResult hostToLatestAppcastItemComparisonResult = (primaryItem != nil) ? [[self versionComparator] compareVersion:self.host.version toVersion:primaryItem.versionString] : NSOrderedSame;
|
||||
|
||||
[self.delegate didNotFindUpdateWithLatestAppcastItem:primaryItem hostToLatestAppcastItemComparisonResult:hostToLatestAppcastItemComparisonResult];
|
||||
}
|
||||
}
|
||||
@@ -212,8 +213,12 @@
|
||||
+ (BOOL)itemOperatingSystemIsOK:(SUAppcastItem *)ui
|
||||
{
|
||||
BOOL osOK = [ui isMacOsUpdate];
|
||||
if (([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) &&
|
||||
([ui maximumSystemVersion] == nil || [[ui maximumSystemVersion] isEqualToString:@""])) {
|
||||
|
||||
NSString *minimumSystemVersion = ui.minimumSystemVersion;
|
||||
NSString *maximumSystemVersion = ui.maximumSystemVersion;
|
||||
|
||||
if ((minimumSystemVersion == nil || [minimumSystemVersion isEqualToString:@""]) &&
|
||||
(maximumSystemVersion == nil || [maximumSystemVersion isEqualToString:@""])) {
|
||||
return osOK;
|
||||
}
|
||||
|
||||
@@ -224,11 +229,11 @@
|
||||
id<SUVersionComparison> versionComparator = [[SUStandardVersionComparator alloc] init];
|
||||
|
||||
// Check minimum and maximum System Version
|
||||
if ([ui minimumSystemVersion] != nil && ![[ui minimumSystemVersion] isEqualToString:@""]) {
|
||||
minimumVersionOK = [versionComparator compareVersion:[ui minimumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedDescending;
|
||||
if (minimumSystemVersion != nil && ![minimumSystemVersion isEqualToString:@""]) {
|
||||
minimumVersionOK = [versionComparator compareVersion:minimumSystemVersion toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedDescending;
|
||||
}
|
||||
if ([ui maximumSystemVersion] != nil && ![[ui maximumSystemVersion] isEqualToString:@""]) {
|
||||
maximumVersionOK = [versionComparator compareVersion:[ui maximumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedAscending;
|
||||
if (maximumSystemVersion != nil && ![maximumSystemVersion isEqualToString:@""]) {
|
||||
maximumVersionOK = [versionComparator compareVersion:maximumSystemVersion toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedAscending;
|
||||
}
|
||||
|
||||
return minimumVersionOK && maximumVersionOK && osOK;
|
||||
@@ -253,19 +258,21 @@
|
||||
|
||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui
|
||||
{
|
||||
return [[self versionComparator] compareVersion:[self.host version] toVersion:[ui versionString]] == NSOrderedAscending;
|
||||
return ui != nil && [[self versionComparator] compareVersion:self.host.version toVersion:ui.versionString] == NSOrderedAscending;
|
||||
}
|
||||
|
||||
- (BOOL)itemPreventsAutoupdate:(SUAppcastItem *)ui
|
||||
{
|
||||
return ([ui minimumAutoupdateVersion] && ! [[ui minimumAutoupdateVersion] isEqualToString:@""] && ([[self versionComparator] compareVersion:[self.host version] toVersion:[ui minimumAutoupdateVersion]] == NSOrderedAscending));
|
||||
NSString *minimumAutoupdateVersion = ui.minimumAutoupdateVersion;
|
||||
return (minimumAutoupdateVersion.length > 0 && ([[self versionComparator] compareVersion:[self.host version] toVersion:minimumAutoupdateVersion] == NSOrderedAscending));
|
||||
}
|
||||
|
||||
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
|
||||
{
|
||||
NSString *skippedVersion = [self.host objectForUserDefaultsKey:SUSkippedVersionKey];
|
||||
if (skippedVersion == nil) { return NO; }
|
||||
return [[self versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
|
||||
|
||||
return [[self versionComparator] compareVersion:ui.versionString toVersion:skippedVersion] != NSOrderedDescending;
|
||||
}
|
||||
|
||||
+ (BOOL)itemIsReadyForPhasedRollout:(SUAppcastItem *)ui phasedUpdateGroup:(NSNumber * _Nullable)phasedUpdateGroup currentDate:(NSDate *)currentDate
|
||||
|
||||
Vendored
+5
-3
@@ -18,13 +18,15 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUAppcastItem (Private)
|
||||
|
||||
// Initializes with data from a dictionary provided by the RSS class.
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict;
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString **)error;
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL *)appcastURL failureReason:(NSString **)error;
|
||||
- (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL failureReason:(NSString * _Nullable __autoreleasing *_Nullable)error;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif /* SUAppcastItem_Private_h */
|
||||
Vendored
+20
-16
@@ -20,34 +20,38 @@
|
||||
#import "SUExport.h"
|
||||
@class SUSignatures;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
SU_EXPORT @interface SUAppcastItem : NSObject<NSSecureCoding>
|
||||
@property (copy, readonly) NSString *title;
|
||||
@property (copy, readonly) NSString *dateString;
|
||||
@property (copy, readonly) NSDate *date;
|
||||
@property (copy, readonly) NSString *itemDescription;
|
||||
@property (strong, readonly) NSURL *releaseNotesURL;
|
||||
@property (strong, readonly) SUSignatures *signatures;
|
||||
@property (copy, readonly) NSString *minimumSystemVersion;
|
||||
@property (copy, readonly) NSString *maximumSystemVersion;
|
||||
@property (strong, readonly) NSURL *fileURL;
|
||||
@property (copy, readonly, nullable) NSString *title;
|
||||
@property (copy, readonly, nullable) NSString *dateString;
|
||||
@property (copy, readonly, nullable) NSDate *date;
|
||||
@property (copy, readonly, nullable) NSString *itemDescription;
|
||||
@property (strong, readonly, nullable) NSURL *releaseNotesURL;
|
||||
@property (strong, readonly, nullable) SUSignatures *signatures;
|
||||
@property (copy, readonly, nullable) NSString *minimumSystemVersion;
|
||||
@property (copy, readonly, nullable) NSString *maximumSystemVersion;
|
||||
@property (strong, readonly, nullable) NSURL *fileURL;
|
||||
@property (nonatomic, readonly) uint64_t contentLength;
|
||||
@property (copy, readonly) NSString *versionString;
|
||||
@property (copy, readonly) NSString *osString;
|
||||
@property (copy, readonly) NSString *displayVersionString;
|
||||
@property (copy, readonly) NSDictionary *deltaUpdates;
|
||||
@property (strong, readonly) NSURL *infoURL;
|
||||
@property (copy, readonly) NSNumber* phasedRolloutInterval;
|
||||
@property (copy, readonly, nullable) NSString *osString;
|
||||
@property (copy, readonly, nullable) NSString *displayVersionString;
|
||||
@property (copy, readonly, nullable) NSDictionary *deltaUpdates;
|
||||
@property (strong, readonly, nullable) NSURL *infoURL;
|
||||
@property (copy, readonly, nullable) NSNumber* phasedRolloutInterval;
|
||||
@property (nonatomic, copy, readonly) NSString *installationType;
|
||||
@property (copy, readonly) NSString *minimumAutoupdateVersion;
|
||||
@property (copy, readonly, nullable) NSString *minimumAutoupdateVersion;
|
||||
|
||||
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
|
||||
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
|
||||
@property (getter=isMacOsUpdate, readonly) BOOL macOsUpdate;
|
||||
@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate;
|
||||
|
||||
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
|
||||
// Returns the dictionary representing the appcast item; this might be useful later for extensions.
|
||||
@property (readonly, copy) NSDictionary *propertiesDictionary;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
Vendored
+53
-24
@@ -69,22 +69,42 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
_fileURL = [decoder decodeObjectOfClass:[NSURL class] forKey:SUAppcastItemFileURLKey];
|
||||
_infoURL = [decoder decodeObjectOfClass:[NSURL class] forKey:SUAppcastItemInfoURLKey];
|
||||
|
||||
_contentLength = (uint64_t)[decoder decodeInt64ForKey:SUAppcastItemContentLengthKey];
|
||||
|
||||
_installationType = [decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemInstallationTypeKey];
|
||||
if (!SPUValidInstallationType(_installationType)) {
|
||||
if (_fileURL == nil && _infoURL == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
_contentLength = (uint64_t)[decoder decodeInt64ForKey:SUAppcastItemContentLengthKey];
|
||||
|
||||
NSString *installationType = [decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemInstallationTypeKey];
|
||||
if (!SPUValidInstallationType(installationType)) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
_installationType = [installationType copy];
|
||||
|
||||
_itemDescription = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemDescriptionKey] copy];
|
||||
_maximumSystemVersion = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemMaximumSystemVersionKey] copy];
|
||||
_minimumSystemVersion = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemMinimumSystemVersionKey] copy];
|
||||
_minimumAutoupdateVersion = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastElementMinimumAutoupdateVersion] copy];
|
||||
_releaseNotesURL = [decoder decodeObjectOfClass:[NSURL class] forKey:SUAppcastItemReleaseNotesURLKey];
|
||||
_title = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemTitleKey] copy];
|
||||
_versionString = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemVersionStringKey] copy];
|
||||
|
||||
NSString *versionString = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemVersionStringKey] copy];
|
||||
if (versionString == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
_versionString = versionString;
|
||||
|
||||
_osString = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastAttributeOsType] copy];
|
||||
_propertiesDictionary = [decoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [NSString class], [NSDate class], [NSArray class]]] forKey:SUAppcastItemPropertiesKey];
|
||||
|
||||
NSDictionary *propertiesDictionary = [decoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [NSString class], [NSDate class], [NSArray class]]] forKey:SUAppcastItemPropertiesKey];
|
||||
if (propertiesDictionary == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
_propertiesDictionary = propertiesDictionary;
|
||||
|
||||
_phasedRolloutInterval = [decoder decodeObjectOfClass:[NSNumber class] forKey:SUAppcastElementPhasedRolloutInterval];
|
||||
}
|
||||
|
||||
@@ -178,7 +198,8 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
|
||||
- (NSDate *)date
|
||||
{
|
||||
if (self.dateString == nil) {
|
||||
NSString *dateString = self.dateString;
|
||||
if (dateString == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -186,7 +207,7 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
|
||||
dateFormatter.dateFormat = @"E, dd MMM yyyy HH:mm:ss Z";
|
||||
|
||||
return [dateFormatter dateFromString:self.dateString];
|
||||
return [dateFormatter dateFromString:dateString];
|
||||
}
|
||||
|
||||
- (BOOL)isInformationOnlyUpdate
|
||||
@@ -199,12 +220,7 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
return [self initWithDictionary:dict relativeToURL:nil failureReason:nil];
|
||||
}
|
||||
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString *__autoreleasing *)error
|
||||
{
|
||||
return [self initWithDictionary:dict relativeToURL:nil failureReason:error];
|
||||
}
|
||||
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL failureReason:(NSString *__autoreleasing *)error
|
||||
- (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL failureReason:(NSString *__autoreleasing *)error
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
@@ -251,7 +267,11 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
if (![theInfoURL isKindOfClass:[NSString class]]) {
|
||||
SULog(SULogLevelError, @"%@ -%@ Info URL is not of valid type.", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
|
||||
} else {
|
||||
_infoURL = [NSURL URLWithString:theInfoURL relativeToURL:appcastURL];
|
||||
if (appcastURL != nil) {
|
||||
_infoURL = [NSURL URLWithString:theInfoURL relativeToURL:appcastURL];
|
||||
} else {
|
||||
_infoURL = [NSURL URLWithString:theInfoURL];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,24 +336,31 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
_displayVersionString = [_versionString copy];
|
||||
}
|
||||
|
||||
_installationType = [enclosure objectForKey:SUAppcastAttributeInstallationType];
|
||||
if (_installationType == nil) {
|
||||
NSString *attributeInstallationType = [enclosure objectForKey:SUAppcastAttributeInstallationType];
|
||||
NSString *chosenInstallationType;
|
||||
if (attributeInstallationType == nil) {
|
||||
// If we have a flat package, assume installation type is guided
|
||||
// (flat / non-archived interactive packages are not supported)
|
||||
// Otherwise assume we have a normal application inside an archive
|
||||
if ([_fileURL.pathExtension isEqualToString:@"pkg"] || [_fileURL.pathExtension isEqualToString:@"mpkg"]) {
|
||||
_installationType = SPUInstallationTypeGuidedPackage;
|
||||
chosenInstallationType = SPUInstallationTypeGuidedPackage;
|
||||
} else {
|
||||
_installationType = SPUInstallationTypeApplication;
|
||||
chosenInstallationType = SPUInstallationTypeApplication;
|
||||
}
|
||||
} else if (!SPUValidInstallationType(_installationType)) {
|
||||
} else if (!SPUValidInstallationType(attributeInstallationType)) {
|
||||
if (error != NULL) {
|
||||
*error = [NSString stringWithFormat:@"Feed item's enclosure lacks valid %@ (found %@)", SUAppcastAttributeInstallationType, _installationType];
|
||||
*error = [NSString stringWithFormat:@"Feed item's enclosure lacks valid %@ (found %@)", SUAppcastAttributeInstallationType, attributeInstallationType];
|
||||
}
|
||||
return nil;
|
||||
} else if ([_installationType isEqualToString:SPUInstallationTypeInteractivePackage]) {
|
||||
} else if ([attributeInstallationType isEqualToString:SPUInstallationTypeInteractivePackage]) {
|
||||
SULog(SULogLevelDefault, @"warning: '%@' for %@ is deprecated. Use '%@' instead.", SPUInstallationTypeInteractivePackage, SUAppcastAttributeInstallationType, SPUInstallationTypeGuidedPackage);
|
||||
|
||||
chosenInstallationType = attributeInstallationType;
|
||||
} else {
|
||||
chosenInstallationType = attributeInstallationType;
|
||||
}
|
||||
|
||||
_installationType = [chosenInstallationType copy];
|
||||
|
||||
// Find the appropriate release notes URL.
|
||||
NSString *releaseNotesString = [dict objectForKey:SUAppcastElementReleaseNotesLink];
|
||||
@@ -350,7 +377,7 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
_releaseNotesURL = url;
|
||||
}
|
||||
} else if ([self.itemDescription hasPrefix:@"http://"] || [self.itemDescription hasPrefix:@"https://"]) { // if the description starts with http:// or https:// use that.
|
||||
_releaseNotesURL = [NSURL URLWithString:self.itemDescription];
|
||||
_releaseNotesURL = [NSURL URLWithString:(NSString * _Nonnull)self.itemDescription];
|
||||
} else {
|
||||
_releaseNotesURL = nil;
|
||||
}
|
||||
@@ -367,7 +394,9 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
[fakeAppCastDict setObject:deltaDictionary forKey:SURSSElementEnclosure];
|
||||
SUAppcastItem *deltaItem = [[SUAppcastItem alloc] initWithDictionary:fakeAppCastDict];
|
||||
|
||||
[deltas setObject:deltaItem forKey:deltaFrom];
|
||||
if (deltaItem != nil) {
|
||||
[deltas setObject:deltaItem forKey:deltaFrom];
|
||||
}
|
||||
}
|
||||
_deltaUpdates = deltas;
|
||||
}
|
||||
|
||||
Vendored
+14
-8
@@ -128,7 +128,10 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
|
||||
- (IBAction)openInfoURL:(id)__unused sender
|
||||
{
|
||||
[[NSWorkspace sharedWorkspace] openURL:self.updateItem.infoURL];
|
||||
NSURL *infoURL = self.updateItem.infoURL;
|
||||
assert(infoURL);
|
||||
|
||||
[[NSWorkspace sharedWorkspace] openURL:infoURL];
|
||||
|
||||
[self endWithSelection:SPUUserUpdateChoiceDismiss];
|
||||
}
|
||||
@@ -167,13 +170,16 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
// Otherwise we'll wait until the client wants us to show release notes
|
||||
if (self.updateItem.releaseNotesURL == nil)
|
||||
{
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
[self.webView loadHTMLString:[self.updateItem itemDescription] baseURL:nil completionHandler:^(NSError * _Nullable error) {
|
||||
if (error != nil) {
|
||||
SULog(SULogLevelError, @"Failed to load HTML string from web view: %@", error);
|
||||
}
|
||||
[weakSelf stopReleaseNotesSpinner];
|
||||
}];
|
||||
NSString *itemDescription = self.updateItem.itemDescription;
|
||||
if (itemDescription != nil) {
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
[self.webView loadHTMLString:itemDescription baseURL:nil completionHandler:^(NSError * _Nullable error) {
|
||||
if (error != nil) {
|
||||
SULog(SULogLevelError, @"Failed to load HTML string from web view: %@", error);
|
||||
}
|
||||
[weakSelf stopReleaseNotesSpinner];
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,13 +53,13 @@ class SUAppcastTest: XCTestCase {
|
||||
let bestAppcastItem = SUAppcastDriver.bestItem(fromAppcastItems: supportedAppcastItems, getDeltaItem: &deltaItem, withHostVersion: "1.0", comparator: SUStandardVersionComparator())
|
||||
|
||||
XCTAssertEqual(bestAppcastItem, items[1])
|
||||
XCTAssertEqual(deltaItem!.fileURL.lastPathComponent, "3.0_from_1.0.patch")
|
||||
XCTAssertEqual(deltaItem!.fileURL!.lastPathComponent, "3.0_from_1.0.patch")
|
||||
|
||||
// Test latest delta update item available
|
||||
var latestDeltaItem: SUAppcastItem?
|
||||
SUAppcastDriver.bestItem(fromAppcastItems: supportedAppcastItems, getDeltaItem: &latestDeltaItem, withHostVersion: "2.0", comparator: SUStandardVersionComparator())
|
||||
|
||||
XCTAssertEqual(latestDeltaItem!.fileURL.lastPathComponent, "3.0_from_2.0.patch")
|
||||
XCTAssertEqual(latestDeltaItem!.fileURL!.lastPathComponent, "3.0_from_2.0.patch")
|
||||
|
||||
// Test a delta item that does not exist
|
||||
var nonexistantDeltaItem: SUAppcastItem?
|
||||
@@ -82,7 +82,7 @@ class SUAppcastTest: XCTestCase {
|
||||
let testFileData = try Data(contentsOf: testFileUrl)
|
||||
let appcast = try SUAppcast(xmlData: testFileData, relativeTo: testFileUrl)
|
||||
let items = appcast.items
|
||||
XCTAssertEqual("https://sparkle-project.org/#localized_notes_link_works", items[0].releaseNotesURL.absoluteString)
|
||||
XCTAssertEqual("https://sparkle-project.org/#localized_notes_link_works", items[0].releaseNotesURL!.absoluteString)
|
||||
} catch let err as NSError {
|
||||
NSLog("%@", err)
|
||||
XCTFail(err.localizedDescription)
|
||||
|
||||
Reference in new issue
Block a user