mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Add optional version field to sparkle:criticalUpdate element
This version indicates the version that was first marked critical. So versions below this specified version will treat the update as critical while versions >= the specified version will not. Also move sparkle:criticalUpdate to root level element instead of it being a tag. The tagged version is now deprecated and doesn't support the version field.
This commit is contained in:
1 parent
433e1bf3de
commit
253f45b476
18 files changed
+195
-37
No files matched your search
@@ -323,6 +323,10 @@
|
||||
7293A1AF1CEE933800B957A7 /* SPUURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */; };
|
||||
7293A1B11CEE9B9F00B957A7 /* SPUURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7293A1AD1CEE933800B957A7 /* SPUURLRequest.m */; };
|
||||
729924941DF4A45000DBCDF5 /* SUUpdateValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 729924931DF4A45000DBCDF5 /* SUUpdateValidator.m */; };
|
||||
729E1D16266490FE00BF3EFB /* SPUAppcastItemSelection.h in Headers */ = {isa = PBXBuildFile; fileRef = 729E1D14266490FE00BF3EFB /* SPUAppcastItemSelection.h */; };
|
||||
729E1D17266490FE00BF3EFB /* SPUAppcastItemSelection.h in Headers */ = {isa = PBXBuildFile; fileRef = 729E1D14266490FE00BF3EFB /* SPUAppcastItemSelection.h */; };
|
||||
729E1D18266490FE00BF3EFB /* SPUAppcastItemSelection.m in Sources */ = {isa = PBXBuildFile; fileRef = 729E1D15266490FE00BF3EFB /* SPUAppcastItemSelection.m */; };
|
||||
729E1D19266490FE00BF3EFB /* SPUAppcastItemSelection.m in Sources */ = {isa = PBXBuildFile; fileRef = 729E1D15266490FE00BF3EFB /* SPUAppcastItemSelection.m */; };
|
||||
72A1C2631CD6849C004CD282 /* SUUpdatePermissionPrompt.h in Headers */ = {isa = PBXBuildFile; fileRef = 612DCBAD0D488BC60015DBEA /* SUUpdatePermissionPrompt.h */; };
|
||||
72A450531C69A68900D67EEA /* SUUpdatePermissionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 72A450511C69A68900D67EEA /* SUUpdatePermissionResponse.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
72A450541C69A68900D67EEA /* SUUpdatePermissionResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 72A450521C69A68900D67EEA /* SUUpdatePermissionResponse.m */; };
|
||||
@@ -1294,6 +1298,8 @@
|
||||
729924921DF4A45000DBCDF5 /* SUUpdateValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUUpdateValidator.h; path = Sparkle/SUUpdateValidator.h; sourceTree = SOURCE_ROOT; };
|
||||
729924931DF4A45000DBCDF5 /* SUUpdateValidator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUUpdateValidator.m; path = Sparkle/SUUpdateValidator.m; sourceTree = SOURCE_ROOT; };
|
||||
729BB3D11D503826007C4276 /* org.sparkle-project.Downloader.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = "org.sparkle-project.Downloader.entitlements"; path = "Downloader/org.sparkle-project.Downloader.entitlements"; sourceTree = SOURCE_ROOT; };
|
||||
729E1D14266490FE00BF3EFB /* SPUAppcastItemSelection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPUAppcastItemSelection.h; sourceTree = "<group>"; };
|
||||
729E1D15266490FE00BF3EFB /* SPUAppcastItemSelection.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SPUAppcastItemSelection.m; sourceTree = "<group>"; };
|
||||
729F10FD1C65A9B500DFCCC5 /* ConfigUITest.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITest.xcconfig; sourceTree = "<group>"; };
|
||||
729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestCoverage.xcconfig; sourceTree = "<group>"; };
|
||||
72A450511C69A68900D67EEA /* SUUpdatePermissionResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdatePermissionResponse.h; sourceTree = "<group>"; };
|
||||
@@ -1877,6 +1883,8 @@
|
||||
61B5FC5309C5182000B25A18 /* SUAppcastItem.h */,
|
||||
725DED73263D123900E7FA8F /* SUAppcastItem+Private.h */,
|
||||
61B5FC5409C5182000B25A18 /* SUAppcastItem.m */,
|
||||
729E1D14266490FE00BF3EFB /* SPUAppcastItemSelection.h */,
|
||||
729E1D15266490FE00BF3EFB /* SPUAppcastItemSelection.m */,
|
||||
721D588B25BE59F900D23BEA /* SUPhasedUpdateGroupInfo.h */,
|
||||
721D588C25BE59F900D23BEA /* SUPhasedUpdateGroupInfo.m */,
|
||||
61A225A20D1C4AC000430CCD /* SUStandardVersionComparator.h */,
|
||||
@@ -2399,6 +2407,7 @@
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
729E1D17266490FE00BF3EFB /* SPUAppcastItemSelection.h in Headers */,
|
||||
7269E495264798200088C213 /* SPUSkippedUpdate.h in Headers */,
|
||||
72A5D5DE1D692ACC0009E5AC /* SparkleCore.h in Headers */,
|
||||
72B3DECE1E23479000457642 /* SPUInformationalUpdate.h in Headers */,
|
||||
@@ -2453,6 +2462,7 @@
|
||||
720E217B1D0D00BF003A311C /* SPUUpdaterCycle.h in Headers */,
|
||||
72F9EC481D5EA904004AC8B6 /* SPUUpdaterDelegate.h in Headers */,
|
||||
726E078D1CA891E9001A286B /* SPUUpdaterSettings.h in Headers */,
|
||||
729E1D16266490FE00BF3EFB /* SPUAppcastItemSelection.h in Headers */,
|
||||
72F9EC3F1D5E823F004AC8B6 /* SPUUpdaterTimer.h in Headers */,
|
||||
7269E494264798200088C213 /* SPUSkippedUpdate.h in Headers */,
|
||||
723ABFC4259D4CB300BDB4FA /* SUWKWebView.h in Headers */,
|
||||
@@ -3574,6 +3584,7 @@
|
||||
72A5D5C51D6929F80009E5AC /* SULog.m in Sources */,
|
||||
72A5D5C61D6929F80009E5AC /* SUOperatingSystem.m in Sources */,
|
||||
72A5D5BE1D6929F80009E5AC /* SUStandardVersionComparator.m in Sources */,
|
||||
729E1D19266490FE00BF3EFB /* SPUAppcastItemSelection.m in Sources */,
|
||||
72A5D5BF1D6929F80009E5AC /* SUSystemProfiler.m in Sources */,
|
||||
72A5D5D71D6929F80009E5AC /* SUUpdatePermissionResponse.m in Sources */,
|
||||
72A5D5B11D6929F80009E5AC /* SUXPCInstallerConnection.m in Sources */,
|
||||
@@ -3674,6 +3685,7 @@
|
||||
7269E496264798200088C213 /* SPUSkippedUpdate.m in Sources */,
|
||||
7269E49A2648F7C00088C213 /* SPUUserUpdateState.m in Sources */,
|
||||
725602D61C83551C00DAA70E /* SUApplicationInfo.m in Sources */,
|
||||
729E1D18266490FE00BF3EFB /* SPUAppcastItemSelection.m in Sources */,
|
||||
7214B8821D456A8500CB5CED /* SUBundleIcon.m in Sources */,
|
||||
72DBA37F1D62C23E002594A8 /* SUCodeSigningVerifier.m in Sources */,
|
||||
61299A6009CA6EB100B7442F /* SUConstants.m in Sources */,
|
||||
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// SPUAppcastItemSelection.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 5/30/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class SUAppcastItem;
|
||||
@class SUHost;
|
||||
@class SPUUpdater;
|
||||
|
||||
@protocol SPUUpdaterDelegate;
|
||||
@protocol SUVersionComparison;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// Functions for querying if appcast item properties that depend on current host version
|
||||
|
||||
BOOL SPUAppcastItemIsCriticalWithComparator(SUAppcastItem *appcastItem, NSString *hostVersion, id<SUVersionComparison> versionComparator);
|
||||
|
||||
BOOL SPUAppcastItemIsCritical(SUAppcastItem *appcastItem, NSString *hostVersion, SPUUpdater *updater, id<SPUUpdaterDelegate> _Nullable updaterDelegate);
|
||||
|
||||
id<SUVersionComparison> SPUVersionComparator(SPUUpdater *updater, id<SPUUpdaterDelegate> _Nullable updaterDelegate);
|
||||
|
||||
BOOL SPUAppcastItemContainsCriticalTag(SUAppcastItem *appcastItem);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
+82
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// SPUAppcastItemSelection.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 5/30/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SPUAppcastItemSelection.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUAppcastItem+Private.h"
|
||||
#import "SPUUpdater.h"
|
||||
#import "SPUUpdaterDelegate.h"
|
||||
#import "SUStandardVersionComparator.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUConstants.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
static NSString * _Nullable SPUAppcastItemCriticalUpdateVersion(SUAppcastItem *appcastItem, BOOL *isCriticalWithoutVersion)
|
||||
{
|
||||
NSDictionary *criticalUpdateDictionary = appcastItem.criticalUpdateDictionary;
|
||||
if (criticalUpdateDictionary == nil) {
|
||||
*isCriticalWithoutVersion = NO;
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *criticalVersion = criticalUpdateDictionary[SUAppcastAttributeVersion];
|
||||
if (criticalVersion == nil || ![criticalVersion isKindOfClass:[NSString class]]) {
|
||||
*isCriticalWithoutVersion = YES;
|
||||
return nil;
|
||||
}
|
||||
|
||||
return criticalVersion;
|
||||
}
|
||||
|
||||
static BOOL SPUCriticalUpdateTest(id<SUVersionComparison> versionComparator, NSString *hostVersion, NSString *criticalVersion)
|
||||
{
|
||||
return ([versionComparator compareVersion:hostVersion toVersion:criticalVersion] == NSOrderedAscending);
|
||||
}
|
||||
|
||||
BOOL SPUAppcastItemIsCriticalWithComparator(SUAppcastItem *appcastItem, NSString *hostVersion, id<SUVersionComparison> versionComparator)
|
||||
{
|
||||
BOOL isCriticalWithoutVersion = NO;
|
||||
NSString *criticalVersion = SPUAppcastItemCriticalUpdateVersion(appcastItem, &isCriticalWithoutVersion);
|
||||
if (criticalVersion == nil) {
|
||||
return isCriticalWithoutVersion;
|
||||
}
|
||||
|
||||
return SPUCriticalUpdateTest(versionComparator, hostVersion, criticalVersion);
|
||||
}
|
||||
|
||||
BOOL SPUAppcastItemIsCritical(SUAppcastItem *appcastItem, NSString *hostVersion, SPUUpdater *updater, id<SPUUpdaterDelegate> _Nullable updaterDelegate)
|
||||
{
|
||||
BOOL isCriticalWithoutVersion = NO;
|
||||
NSString *criticalVersion = SPUAppcastItemCriticalUpdateVersion(appcastItem, &isCriticalWithoutVersion);
|
||||
if (criticalVersion == nil) {
|
||||
return isCriticalWithoutVersion;
|
||||
}
|
||||
|
||||
id<SUVersionComparison> versionComparator = SPUVersionComparator(updater, updaterDelegate);
|
||||
return SPUCriticalUpdateTest(versionComparator, hostVersion, criticalVersion);
|
||||
}
|
||||
|
||||
id<SUVersionComparison> SPUVersionComparator(SPUUpdater *updater, id<SPUUpdaterDelegate> _Nullable updaterDelegate)
|
||||
{
|
||||
id<SUVersionComparison> comparator = nil;
|
||||
|
||||
// Give the delegate a chance to provide a custom version comparator
|
||||
if ([updaterDelegate respondsToSelector:@selector((versionComparatorForUpdater:))]) {
|
||||
comparator = [updaterDelegate versionComparatorForUpdater:(id _Nonnull)updater];
|
||||
}
|
||||
|
||||
// If we don't get a comparator from the delegate, use the default comparator
|
||||
if (comparator == nil) {
|
||||
comparator = [SUStandardVersionComparator defaultComparator];
|
||||
}
|
||||
|
||||
return comparator;
|
||||
}
|
||||
Vendored
+6
-1
@@ -15,12 +15,14 @@
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SPUUserDriver.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SPUAppcastItemSelection.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SPUAutomaticUpdateDriver () <SPUCoreBasedUpdateDriverDelegate>
|
||||
|
||||
@property (nonatomic, readonly) SUHost *host;
|
||||
@property (nonatomic, readonly, weak) id updater;
|
||||
@property (nonatomic, readonly, weak) id<SPUUserDriver> userDriver;
|
||||
@property (nonatomic, readonly, weak, nullable) id updaterDelegate;
|
||||
@@ -32,6 +34,7 @@
|
||||
|
||||
@implementation SPUAutomaticUpdateDriver
|
||||
|
||||
@synthesize host = _host;
|
||||
@synthesize updater = _updater;
|
||||
@synthesize userDriver = _userDriver;
|
||||
@synthesize updaterDelegate = _updaterDelegate;
|
||||
@@ -43,6 +46,7 @@
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_host = host;
|
||||
_updater = updater;
|
||||
// The user driver is only used for a termination callback
|
||||
_userDriver = userDriver;
|
||||
@@ -133,7 +137,8 @@
|
||||
|
||||
- (void)abortUpdateWithError:(NSError *)error
|
||||
{
|
||||
BOOL showNextUpdateImmediately = (error == nil || error.code == SUInstallationAuthorizeLaterError) && (!self.willInstallSilently || self.updateItem.isCriticalUpdate || self.updateItem.isInformationOnlyUpdate);
|
||||
BOOL showNextUpdateImmediately = (error == nil || error.code == SUInstallationAuthorizeLaterError) && (!self.willInstallSilently || SPUAppcastItemIsCritical(self.updateItem, self.host.version, self.updater, self.updaterDelegate) || self.updateItem.isInformationOnlyUpdate);
|
||||
|
||||
[self.coreDriver abortUpdateAndShowNextUpdateImmediately:showNextUpdateImmediately error:error];
|
||||
}
|
||||
|
||||
|
||||
Vendored
+3
-1
@@ -19,6 +19,7 @@
|
||||
#import "SPUDownloadDriver.h"
|
||||
#import "SPUSkippedUpdate.h"
|
||||
#import "SPUUserUpdateState+Private.h"
|
||||
#import "SPUAppcastItemSelection.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
@@ -181,8 +182,9 @@
|
||||
}
|
||||
|
||||
BOOL majorUpgrade = preventsAutoupdate;
|
||||
BOOL criticalUpdate = SPUAppcastItemIsCritical(updateItem, self.host.version, self.updater, self.updaterDelegate);
|
||||
|
||||
SPUUserUpdateState *state = [[SPUUserUpdateState alloc] initWithStage:stage userInitiated:self.userInitiated majorUpgrade:majorUpgrade];
|
||||
SPUUserUpdateState *state = [[SPUUserUpdateState alloc] initWithStage:stage userInitiated:self.userInitiated majorUpgrade:majorUpgrade criticalUpdate:criticalUpdate];
|
||||
|
||||
[self.userDriver showUpdateFoundWithAppcastItem:updateItem state:state reply:^(SPUUserUpdateChoice userChoice) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
Vendored
+2
-1
@@ -30,6 +30,7 @@
|
||||
#import "SPUUpdaterTimer.h"
|
||||
#import "SPUResumableUpdate.h"
|
||||
#import "SUSignatures.h"
|
||||
#import "SPUAppcastItemSelection.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
@@ -884,7 +885,7 @@ static NSString *escapeURLComponent(NSString *str) {
|
||||
// Proceed as normal if there's no resumable updates
|
||||
completionHandler(regularCheckInterval);
|
||||
} else {
|
||||
if (!installationInfo.canSilentlyInstall || [installationInfo.appcastItem isCriticalUpdate] || [installationInfo.appcastItem isInformationOnlyUpdate]) {
|
||||
if (!installationInfo.canSilentlyInstall || SPUAppcastItemIsCritical(((SPUInstallationInfo * _Nonnull)installationInfo).appcastItem, self.host.version, self, self.delegate) || [installationInfo.appcastItem isInformationOnlyUpdate]) {
|
||||
completionHandler(MIN(regularCheckInterval, SUImpatientUpdateCheckInterval));
|
||||
} else {
|
||||
completionHandler(MAX(regularCheckInterval, SUImpatientUpdateCheckInterval));
|
||||
|
||||
Vendored
+1
-1
@@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SPUUserUpdateState (Private)
|
||||
|
||||
- (instancetype)initWithStage:(SPUUserUpdateStage)stage userInitiated:(BOOL)userInitiated majorUpgrade:(BOOL)majorUpgrade;
|
||||
- (instancetype)initWithStage:(SPUUserUpdateStage)stage userInitiated:(BOOL)userInitiated majorUpgrade:(BOOL)majorUpgrade criticalUpdate:(BOOL)criticalUpdate;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+1
@@ -40,6 +40,7 @@ SU_EXPORT @interface SPUUserUpdateState : NSObject
|
||||
@property (nonatomic, readonly) SPUUserUpdateStage stage;
|
||||
@property (nonatomic, readonly) BOOL userInitiated;
|
||||
@property (nonatomic, readonly) BOOL majorUpgrade;
|
||||
@property (nonatomic, readonly) BOOL criticalUpdate;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+7
-2
@@ -15,20 +15,23 @@
|
||||
#define SPUUserUpdateStateStageKey @"SPUUserUpdateStateStage"
|
||||
#define SPUUserUpdateStateUserInitiatedKey @"SPUUserUpdateStateUserInitiated"
|
||||
#define SPUUserUpdateStateMajorUpgradeKey @"SPUUserUpdateStateMajorUpgrade"
|
||||
#define SPUUserUpdateStateCriticalUpdateKey @"SPUUserUpdateStateCriticalUpdate"
|
||||
|
||||
@implementation SPUUserUpdateState
|
||||
|
||||
@synthesize stage = _stage;
|
||||
@synthesize userInitiated = _userInitiated;
|
||||
@synthesize majorUpgrade = _majorUpgrade;
|
||||
@synthesize criticalUpdate = _criticalUpdate;
|
||||
|
||||
- (instancetype)initWithStage:(SPUUserUpdateStage)stage userInitiated:(BOOL)userInitiated majorUpgrade:(BOOL)majorUpgrade
|
||||
- (instancetype)initWithStage:(SPUUserUpdateStage)stage userInitiated:(BOOL)userInitiated majorUpgrade:(BOOL)majorUpgrade criticalUpdate:(BOOL)criticalUpdate
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_stage = stage;
|
||||
_userInitiated = userInitiated;
|
||||
_majorUpgrade = majorUpgrade;
|
||||
_criticalUpdate = criticalUpdate;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -38,6 +41,7 @@
|
||||
[encoder encodeInteger:self.stage forKey:SPUUserUpdateStateStageKey];
|
||||
[encoder encodeBool:self.userInitiated forKey:SPUUserUpdateStateUserInitiatedKey];
|
||||
[encoder encodeBool:self.majorUpgrade forKey:SPUUserUpdateStateMajorUpgradeKey];
|
||||
[encoder encodeBool:self.criticalUpdate forKey:SPUUserUpdateStateCriticalUpdateKey];
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)decoder
|
||||
@@ -45,8 +49,9 @@
|
||||
SPUUserUpdateStage stage = [decoder decodeIntegerForKey:SPUUserUpdateStateStageKey];
|
||||
BOOL userInitiated = [decoder decodeBoolForKey:SPUUserUpdateStateUserInitiatedKey];
|
||||
BOOL majorUpgrade = [decoder decodeBoolForKey:SPUUserUpdateStateMajorUpgradeKey];
|
||||
BOOL criticalUpdate = [decoder decodeBoolForKey:SPUUserUpdateStateCriticalUpdateKey];
|
||||
|
||||
return [self initWithStage:stage userInitiated:userInitiated majorUpgrade:majorUpgrade];
|
||||
return [self initWithStage:stage userInitiated:userInitiated majorUpgrade:majorUpgrade criticalUpdate:criticalUpdate];
|
||||
}
|
||||
|
||||
+ (BOOL)supportsSecureCoding
|
||||
|
||||
Vendored
+4
-4
@@ -119,10 +119,10 @@
|
||||
|
||||
for (NSString *name in nodesDict) {
|
||||
node = [self bestNodeInNodes:[nodesDict objectForKey:name]];
|
||||
if ([name isEqualToString:SURSSElementEnclosure]) {
|
||||
// enclosure is flattened as a separate dictionary for some reason
|
||||
NSDictionary *encDict = [self attributesOfNode:(NSXMLElement *)node];
|
||||
[dict setObject:encDict forKey:name];
|
||||
if ([name isEqualToString:SURSSElementEnclosure] || [name isEqualToString:SUAppcastElementCriticalUpdate]) {
|
||||
// These are flattened as a separate dictionary for some reason
|
||||
NSDictionary *innerDict = [self attributesOfNode:(NSXMLElement *)node];
|
||||
[dict setObject:innerDict forKey:name];
|
||||
}
|
||||
else if ([name isEqualToString:SURSSElementPubDate]) {
|
||||
// We don't want to parse and create a NSDate instance -
|
||||
|
||||
Vendored
+6
-17
@@ -23,6 +23,7 @@
|
||||
#import "SPUDownloadData.h"
|
||||
#import "SULocalizations.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SPUAppcastItemSelection.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
@@ -30,7 +31,7 @@
|
||||
@interface SUAppcastDriver () <SPUDownloadDriverDelegate>
|
||||
|
||||
@property (nonatomic, readonly) SUHost *host;
|
||||
@property (nullable, nonatomic, readonly, weak) id updater;
|
||||
@property (nonatomic, readonly, weak) id updater;
|
||||
@property (nullable, nonatomic, readonly, weak) id <SPUUpdaterDelegate> updaterDelegate;
|
||||
@property (nullable, nonatomic, readonly, weak) id <SUAppcastDriverDelegate> delegate;
|
||||
@property (nonatomic) SPUDownloadDriver *downloadDriver;
|
||||
@@ -237,7 +238,7 @@
|
||||
return [appcast copyByFilteringItems:^(SUAppcastItem *item) {
|
||||
BOOL passesOSVersion = (!testOSVersion || [self isItemMinimumAndMaximumOperatingSystemVersionOK:item]);
|
||||
|
||||
BOOL passesPhasedRollout = [self itemIsReadyForPhasedRollout:item phasedUpdateGroup:phasedUpdateGroup currentDate:currentDate];
|
||||
BOOL passesPhasedRollout = [self itemIsReadyForPhasedRollout:item phasedUpdateGroup:phasedUpdateGroup currentDate:currentDate hostVersion:hostVersion versionComparator:versionComparator];
|
||||
|
||||
BOOL passesMinimumAutoupdateVersion = (!testMinimumAutoupdateVersion || hostVersion == nil || versionComparator == nil || [self isItemMinimumAutoupdateVersionOK:item.minimumAutoupdateVersion hostVersion:hostVersion versionComparator:versionComparator]);
|
||||
|
||||
@@ -310,19 +311,7 @@
|
||||
|
||||
- (id<SUVersionComparison>)versionComparator
|
||||
{
|
||||
id<SUVersionComparison> comparator = nil;
|
||||
|
||||
// Give the delegate a chance to provide a custom version comparator
|
||||
if ([self.updaterDelegate respondsToSelector:@selector((versionComparatorForUpdater:))]) {
|
||||
comparator = [self.updaterDelegate versionComparatorForUpdater:(id _Nonnull)self.updater];
|
||||
}
|
||||
|
||||
// If we don't get a comparator from the delegate, use the default comparator
|
||||
if (!comparator) {
|
||||
comparator = [[SUStandardVersionComparator alloc] init];
|
||||
}
|
||||
|
||||
return comparator;
|
||||
return SPUVersionComparator(self.updater, self.updaterDelegate);
|
||||
}
|
||||
|
||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui
|
||||
@@ -351,9 +340,9 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (BOOL)itemIsReadyForPhasedRollout:(SUAppcastItem *)ui phasedUpdateGroup:(NSNumber * _Nullable)phasedUpdateGroup currentDate:(NSDate *)currentDate
|
||||
+ (BOOL)itemIsReadyForPhasedRollout:(SUAppcastItem *)ui phasedUpdateGroup:(NSNumber * _Nullable)phasedUpdateGroup currentDate:(NSDate *)currentDate hostVersion:(NSString *)hostVersion versionComparator:(id<SUVersionComparison>)versionComparator
|
||||
{
|
||||
if (phasedUpdateGroup == nil || [ui isCriticalUpdate]) {
|
||||
if (phasedUpdateGroup == nil || SPUAppcastItemIsCriticalWithComparator(ui, hostVersion, versionComparator)) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
@@ -25,6 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// Initializes with data from a dictionary provided by the RSS class.
|
||||
- (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL failureReason:(NSString * _Nullable __autoreleasing *_Nullable)error;
|
||||
|
||||
@property (nullable, nonatomic, readonly) NSDictionary *criticalUpdateDictionary;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
Vendored
+1
-1
@@ -43,7 +43,7 @@ SU_EXPORT @interface SUAppcastItem : NSObject<NSSecureCoding>
|
||||
@property (copy, readonly, nullable) NSString *minimumAutoupdateVersion;
|
||||
|
||||
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
|
||||
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
|
||||
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate __deprecated_msg("Use SPUUserUpdateState.criticalUpdate instead");
|
||||
@property (getter=isMacOsUpdate, readonly) BOOL macOsUpdate;
|
||||
@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate;
|
||||
|
||||
|
||||
Vendored
+22
-1
@@ -188,7 +188,28 @@ static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationT
|
||||
|
||||
- (BOOL)isCriticalUpdate
|
||||
{
|
||||
return [(NSArray *)[self.propertiesDictionary objectForKey:SUAppcastElementTags] containsObject:SUAppcastElementCriticalUpdate];
|
||||
return self.criticalUpdateDictionary != nil;
|
||||
}
|
||||
|
||||
- (NSDictionary * _Nullable)criticalUpdateDictionary
|
||||
{
|
||||
NSDictionary *criticalUpdateDictionary = self.propertiesDictionary[SUAppcastElementCriticalUpdate];
|
||||
if (criticalUpdateDictionary != nil) {
|
||||
return criticalUpdateDictionary;
|
||||
}
|
||||
|
||||
NSArray *tags = [self.propertiesDictionary objectForKey:SUAppcastElementTags];
|
||||
if ([tags isKindOfClass:[NSArray class]] && [tags containsObject:SUAppcastElementCriticalUpdate]) {
|
||||
return @{};
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)containsCriticalUpdateTag
|
||||
{
|
||||
NSArray *tags = [self.propertiesDictionary objectForKey:SUAppcastElementTags];
|
||||
return [tags isKindOfClass:[NSArray class]] && [tags containsObject:SUAppcastElementCriticalUpdate];
|
||||
}
|
||||
|
||||
- (BOOL)isMacOsUpdate
|
||||
|
||||
Vendored
+3
-3
@@ -380,7 +380,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
self.laterButton.title = SULocalizedString(@"Install on Quit", @"Alternate title for 'Remind Me Later' button when downloaded updates can be resumed");
|
||||
}
|
||||
|
||||
if ([self.updateItem isCriticalUpdate] && !self.state.majorUpgrade) {
|
||||
if (self.state.criticalUpdate && !self.state.majorUpgrade) {
|
||||
self.skipButton.hidden = YES;
|
||||
self.laterButton.hidden = YES;
|
||||
}
|
||||
@@ -406,7 +406,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
|
||||
- (NSString *)titleText
|
||||
{
|
||||
if ([self.updateItem isCriticalUpdate])
|
||||
if (self.state.criticalUpdate)
|
||||
{
|
||||
return [NSString stringWithFormat:SULocalizedString(@"An important update to %@ is ready to install", nil), [self.host name]];
|
||||
}
|
||||
@@ -437,7 +437,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
|
||||
|
||||
if (self.state.stage == SPUUserUpdateStageInformational) {
|
||||
finalString = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?", @"Description text for SUUpdateAlert when the update informational with no download."), self.host.name, updateItemVersion, hostVersion];
|
||||
} else if ([self.updateItem isCriticalUpdate]) {
|
||||
} else if (self.state.criticalUpdate) {
|
||||
if (self.state.stage == SPUUserUpdateStageNotDownloaded) {
|
||||
finalString = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. This is an important update; would you like to download it now?", @"Description text for SUUpdateAlert when the critical update is downloadable."), self.host.name, updateItemVersion, hostVersion];
|
||||
} else {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<description>desc</description>
|
||||
<pubDate>Sat, 26 Jul 2014 15:20:11 +0000</pubDate>
|
||||
<enclosure url="http://localhost:1337/Sparkle_Test_App.zip" sparkle:version="2.0" />
|
||||
<sparkle:tags> <sparkle:criticalUpdate /> </sparkle:tags>
|
||||
<sparkle:criticalUpdate sparkle:version="1.5" />
|
||||
</item>
|
||||
<!-- The best chosen release -->
|
||||
<item>
|
||||
|
||||
@@ -21,28 +21,35 @@ class SUAppcastTest: XCTestCase {
|
||||
let items = appcast.items
|
||||
|
||||
XCTAssertEqual(4, items.count)
|
||||
|
||||
let standardComparator = SUStandardVersionComparator()
|
||||
|
||||
XCTAssertEqual("Version 2.0", items[0].title)
|
||||
XCTAssertEqual("desc", items[0].itemDescription)
|
||||
XCTAssertEqual("Sat, 26 Jul 2014 15:20:11 +0000", items[0].dateString)
|
||||
XCTAssertTrue(items[0].isCriticalUpdate)
|
||||
XCTAssertTrue(SPUAppcastItemIsCriticalWithComparator(items[0], "1.0", standardComparator))
|
||||
XCTAssertFalse(SPUAppcastItemIsCriticalWithComparator(items[0], "1.5", standardComparator))
|
||||
XCTAssertFalse(SPUAppcastItemIsCriticalWithComparator(items[0], "2.0", standardComparator))
|
||||
|
||||
// This is the best release matching our system version
|
||||
XCTAssertEqual("Version 3.0", items[1].title)
|
||||
XCTAssertNil(items[1].itemDescription)
|
||||
XCTAssertNil(items[1].dateString)
|
||||
XCTAssertFalse(items[1].isCriticalUpdate)
|
||||
XCTAssertFalse(SPUAppcastItemIsCriticalWithComparator(items[1], "1.0", standardComparator))
|
||||
XCTAssertFalse(SPUAppcastItemIsCriticalWithComparator(items[1], "2.0", standardComparator))
|
||||
XCTAssertEqual(items[1].phasedRolloutInterval, 86400)
|
||||
|
||||
XCTAssertEqual("Version 4.0", items[2].title)
|
||||
XCTAssertNil(items[2].itemDescription)
|
||||
XCTAssertEqual("Sat, 26 Jul 2014 15:20:13 +0000", items[2].dateString)
|
||||
XCTAssertFalse(items[2].isCriticalUpdate)
|
||||
XCTAssertFalse(SPUAppcastItemIsCriticalWithComparator(items[2], "1.0", standardComparator))
|
||||
XCTAssertFalse(SPUAppcastItemIsCriticalWithComparator(items[2], "2.0", standardComparator))
|
||||
|
||||
XCTAssertEqual("Version 5.0", items[3].title)
|
||||
XCTAssertNil(items[3].itemDescription)
|
||||
XCTAssertNil(items[3].dateString)
|
||||
XCTAssertFalse(items[3].isCriticalUpdate)
|
||||
XCTAssertFalse(SPUAppcastItemIsCriticalWithComparator(items[3], "1.0", standardComparator))
|
||||
XCTAssertFalse(SPUAppcastItemIsCriticalWithComparator(items[3], "2.0", standardComparator))
|
||||
|
||||
// Test best appcast item & a delta update item
|
||||
let supportedAppcast = SUAppcastDriver.filterSupportedAppcast(appcast, phasedUpdateGroup: nil, skippedUpdate: nil, hostVersion: nil, versionComparator: nil, testOSVersion: true, testMinimumAutoupdateVersion: false)
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#import "SPUSkippedUpdate.h"
|
||||
#import "SUSignatures.h"
|
||||
#import "SPUInstallationType.h"
|
||||
#import "SPUAppcastItemSelection.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
Reference in new issue
Block a user