mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-28 05:14:34 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1adbbccf5e | ||
|
|
d792a3a4a9 | ||
|
|
32bc43fa9b | ||
|
|
4b9388d9aa | ||
|
|
c53ed49e5e | ||
|
|
011a7dbb36 | ||
|
|
fb1f5aafbe | ||
|
|
52511a2b1c |
No files matched your search
@@ -71,7 +71,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
git config user.name Sparkle-Bot
|
git config user.name Sparkle-Bot
|
||||||
git config user.email sparkle.project.bot@gmail.com
|
git config user.email sparkle.project.bot@gmail.com
|
||||||
git tag "${{ github.event.inputs.marketingVersion }}"
|
git tag "${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
|
||||||
|
|
||||||
- name: "Build release distribution"
|
- name: "Build release distribution"
|
||||||
run: make release
|
run: make release
|
||||||
@@ -90,8 +90,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
draft: true
|
draft: true
|
||||||
prerelease: ${{ env.PRERELEASE_VERSION }}
|
prerelease: ${{ env.PRERELEASE_VERSION }}
|
||||||
name: "Sparkle ${{ github.event.inputs.marketingVersion }}"
|
name: "Sparkle ${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
|
||||||
tag_name: ${{ github.event.inputs.marketingVersion }}
|
tag_name: "${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}"
|
||||||
fail_on_unmatched_files: true
|
fail_on_unmatched_files: true
|
||||||
token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
|
token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
|
||||||
body_path: latest-changes.txt
|
body_path: latest-changes.txt
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ If you are migrating from earlier alpha versions of Sparkle 2, please re-familia
|
|||||||
* Fix to prevent Sparkle manipulating the host app's high level WebView defaults from #1961 (affecting only macOS versions before 10.11 in 1.x branch) (Daniel Jalkut)
|
* Fix to prevent Sparkle manipulating the host app's high level WebView defaults from #1961 (affecting only macOS versions before 10.11 in 1.x branch) (Daniel Jalkut)
|
||||||
* Add safer handling of applying binary delta files from #1990 (Zorg)
|
* Add safer handling of applying binary delta files from #1990 (Zorg)
|
||||||
* Don't use current date unless necessary when scheduling next update to be more resilient against rapid polling from #1991 (Zorg)
|
* Don't use current date unless necessary when scheduling next update to be more resilient against rapid polling from #1991 (Zorg)
|
||||||
|
* Prevent potential rapid update checks from sleep/wake events using a minimum monotonic delay from #2000 (Zorg)
|
||||||
|
* Whitelist about:srcdoc as a safe web URL from #1938, #2007 (Louis Pontoise, Zorg)
|
||||||
|
* Backport not hiding update window on deactivation from #2008 (Zorg)
|
||||||
|
|
||||||
# 1.27.0
|
# 1.27.0
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ SPARKLE_VERSION_PATCH = 0
|
|||||||
|
|
||||||
// This should be in SemVer format or empty, ie. "-beta.1"
|
// This should be in SemVer format or empty, ie. "-beta.1"
|
||||||
// These variables must have a space after the '=' too
|
// These variables must have a space after the '=' too
|
||||||
SPARKLE_VERSION_SUFFIX = -beta.4
|
SPARKLE_VERSION_SUFFIX = -beta.5
|
||||||
CURRENT_PROJECT_VERSION = 2004
|
CURRENT_PROJECT_VERSION = 2005
|
||||||
|
|
||||||
MARKETING_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)$(SPARKLE_VERSION_SUFFIX)
|
MARKETING_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)$(SPARKLE_VERSION_SUFFIX)
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO
|
ALWAYS_SEARCH_USER_PATHS = NO
|
||||||
|
|||||||
+3
-3
@@ -2,10 +2,10 @@
|
|||||||
import PackageDescription
|
import PackageDescription
|
||||||
|
|
||||||
// Version is technically not required here, SPM doesn't check
|
// Version is technically not required here, SPM doesn't check
|
||||||
let version = "2.0.0-beta.4"
|
let version = "2.0.0-beta.5"
|
||||||
// Tag is required to point towards the right asset. SPM requires the tag to follow semantic versioning to be able to resolve it.
|
// Tag is required to point towards the right asset. SPM requires the tag to follow semantic versioning to be able to resolve it.
|
||||||
let tag = "2.0.0-beta.4"
|
let tag = "2.0.0-beta.5"
|
||||||
let checksum = "4f863dc048e8c4170e0c3fdbdb9a9b03af605adbd778aa11799db3f34068202d"
|
let checksum = "a53a83db87a5e705d58227f6d9088c76425ddb00e0a9eded87ae845ce5903529"
|
||||||
let url = "https://github.com/sparkle-project/Sparkle/releases/download/\(tag)/Sparkle-for-Swift-Package-Manager.zip"
|
let url = "https://github.com/sparkle-project/Sparkle/releases/download/\(tag)/Sparkle-for-Swift-Package-Manager.zip"
|
||||||
|
|
||||||
let package = Package(
|
let package = Package(
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = "Sparkle"
|
s.name = "Sparkle"
|
||||||
s.version = "2.0.0-beta.4"
|
s.version = "2.0.0-beta.5"
|
||||||
s.summary = "A software update framework for macOS"
|
s.summary = "A software update framework for macOS"
|
||||||
s.description = "Sparkle is an easy-to-use software update framework for macOS."
|
s.description = "Sparkle is an easy-to-use software update framework for macOS."
|
||||||
s.homepage = "https://sparkle-project.org"
|
s.homepage = "https://sparkle-project.org"
|
||||||
|
|||||||
Vendored
+3
-1
@@ -279,12 +279,14 @@ SU_EXPORT @interface SPUUpdater : NSObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Appropriately schedules or cancels the update checking timer according to the preferences for time interval and automatic checks.
|
Appropriately schedules or cancels the update checking timer according to the preferences for time interval and automatic checks.
|
||||||
|
|
||||||
|
If you change the `updateCheckInterval` or `automaticallyChecksForUpdates` properties, the update cycle will be reset automatically after a short delay.
|
||||||
|
The update cycle is also started automatically after the updater is started. In these cases, this method should not be called directly.
|
||||||
|
|
||||||
This call does not change the date of the next check, but only the internal timer.
|
This call does not change the date of the next check, but only the internal timer.
|
||||||
*/
|
*/
|
||||||
- (void)resetUpdateCycle;
|
- (void)resetUpdateCycle;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The system profile information that is sent when checking for updates.
|
The system profile information that is sent when checking for updates.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Vendored
+71
-19
@@ -62,6 +62,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
|||||||
@property (nonatomic) BOOL showingPermissionRequest;
|
@property (nonatomic) BOOL showingPermissionRequest;
|
||||||
|
|
||||||
@property (nonatomic, copy) NSDate *updateLastCheckedDate;
|
@property (nonatomic, copy) NSDate *updateLastCheckedDate;
|
||||||
|
@property (nonatomic) NSTimeInterval lastMonotonicUpdateCheckTime;
|
||||||
|
|
||||||
@property (nonatomic) BOOL loggedATSWarning;
|
@property (nonatomic) BOOL loggedATSWarning;
|
||||||
@property (nonatomic) BOOL loggedNoSecureKeyWarning;
|
@property (nonatomic) BOOL loggedNoSecureKeyWarning;
|
||||||
@@ -87,6 +88,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
|||||||
@synthesize canCheckForUpdates = _canCheckForUpdates;
|
@synthesize canCheckForUpdates = _canCheckForUpdates;
|
||||||
@synthesize showingPermissionRequest = _showingPermissionRequest;
|
@synthesize showingPermissionRequest = _showingPermissionRequest;
|
||||||
@synthesize updateLastCheckedDate = _updateLastCheckedDate;
|
@synthesize updateLastCheckedDate = _updateLastCheckedDate;
|
||||||
|
@synthesize lastMonotonicUpdateCheckTime = _lastMonotonicUpdateCheckTime;
|
||||||
@synthesize loggedATSWarning = _loggedATSWarning;
|
@synthesize loggedATSWarning = _loggedATSWarning;
|
||||||
@synthesize loggedNoSecureKeyWarning = _loggedNoSecureKeyWarning;
|
@synthesize loggedNoSecureKeyWarning = _loggedNoSecureKeyWarning;
|
||||||
|
|
||||||
@@ -402,7 +404,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
|||||||
// We start the update checks and register as observer for changes after the prompt finishes
|
// We start the update checks and register as observer for changes after the prompt finishes
|
||||||
} else {
|
} else {
|
||||||
// We check if the user's said they want updates, or they haven't said anything, and the default is set to checking.
|
// We check if the user's said they want updates, or they haven't said anything, and the default is set to checking.
|
||||||
[self scheduleNextUpdateCheckFiringImmediately:NO usingCurrentTime:YES];
|
[self scheduleNextUpdateCheckFiringImmediately:NO usingCurrentDate:YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,17 +424,27 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
|||||||
return [self updateLastCheckedDate];
|
return [self updateLastCheckedDate];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSTimeInterval)currentMonotonicTimeInterval
|
||||||
|
{
|
||||||
|
// This is monotonic system time while the system is not asleep
|
||||||
|
return [[NSProcessInfo processInfo] systemUptime];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)updateLastUpdateCheckDate
|
- (void)updateLastUpdateCheckDate
|
||||||
{
|
{
|
||||||
[self willChangeValueForKey:NSStringFromSelector(@selector((lastUpdateCheckDate)))];
|
[self willChangeValueForKey:NSStringFromSelector(@selector((lastUpdateCheckDate)))];
|
||||||
|
|
||||||
// We use an intermediate property for last update check date due to https://github.com/sparkle-project/Sparkle/pull/1135
|
// We use an intermediate property for last update check date due to https://github.com/sparkle-project/Sparkle/pull/1135
|
||||||
[self setUpdateLastCheckedDate:[NSDate date]];
|
[self setUpdateLastCheckedDate:[NSDate date]];
|
||||||
[self.host setObject:[self updateLastCheckedDate] forUserDefaultsKey:SULastCheckTimeKey];
|
[self.host setObject:[self updateLastCheckedDate] forUserDefaultsKey:SULastCheckTimeKey];
|
||||||
|
|
||||||
|
self.lastMonotonicUpdateCheckTime = [self currentMonotonicTimeInterval];
|
||||||
|
|
||||||
[self didChangeValueForKey:NSStringFromSelector(@selector((lastUpdateCheckDate)))];
|
[self didChangeValueForKey:NSStringFromSelector(@selector((lastUpdateCheckDate)))];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note this method is never called when sessionInProgress is YES
|
// Note this method is never called when sessionInProgress is YES
|
||||||
- (void)scheduleNextUpdateCheckFiringImmediately:(BOOL)firingImmediately usingCurrentTime:(BOOL)usingCurrentTime
|
- (void)scheduleNextUpdateCheckFiringImmediately:(BOOL)firingImmediately usingCurrentDate:(BOOL)usingCurrentDate
|
||||||
{
|
{
|
||||||
[self.updaterTimer invalidate];
|
[self.updaterTimer invalidate];
|
||||||
|
|
||||||
@@ -479,34 +491,74 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
|||||||
// This callback is asynchronous, so the timer may be set. Invalidate to make sure it isn't.
|
// This callback is asynchronous, so the timer may be set. Invalidate to make sure it isn't.
|
||||||
[self.updaterTimer invalidate];
|
[self.updaterTimer invalidate];
|
||||||
|
|
||||||
NSTimeInterval intervalSinceCheck;
|
NSTimeInterval dateIntervalSinceCheck;
|
||||||
if (usingCurrentTime) {
|
NSTimeInterval minimumMonotonicEnforcedDelay;
|
||||||
|
if (usingCurrentDate) {
|
||||||
// How long has it been since last we checked for an update?
|
// How long has it been since last we checked for an update?
|
||||||
NSDate *lastCheckDate = [self lastUpdateCheckDate];
|
NSDate *lastCheckDate = [self lastUpdateCheckDate];
|
||||||
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
|
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
|
||||||
intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
|
NSTimeInterval wallTimeInterval = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
|
||||||
if (intervalSinceCheck < 0) {
|
if (wallTimeInterval < 0) {
|
||||||
// Last update check date is in the future and bogus, so reset it to current date
|
// Last update check date is in the future and bogus, so reset it to current date
|
||||||
[self updateLastUpdateCheckDate];
|
[self updateLastUpdateCheckDate];
|
||||||
|
|
||||||
intervalSinceCheck = 0;
|
// And assume a full update interval is needed
|
||||||
|
dateIntervalSinceCheck = 0;
|
||||||
|
minimumMonotonicEnforcedDelay = SUMinimumMonotonicUpdateCheckInterval;
|
||||||
|
} else {
|
||||||
|
// Check the monotonic clock for an enforced minimum delay
|
||||||
|
NSTimeInterval lastMonotonicUpdateCheckTime = self.lastMonotonicUpdateCheckTime;
|
||||||
|
if (lastMonotonicUpdateCheckTime <= 0) {
|
||||||
|
// When the updater is first started, the last monotonic time may not have been updated yet.
|
||||||
|
// In this case there is no enforced minimum delay.
|
||||||
|
minimumMonotonicEnforcedDelay = 0;
|
||||||
|
} else {
|
||||||
|
// Compute an enforced minimum delay based on elapsed monotonic time
|
||||||
|
// The elapsed monotonic time is more stable than wall time interval and does not include the
|
||||||
|
// amount of time while the system is asleep
|
||||||
|
NSTimeInterval currentMonotonicTime = [self currentMonotonicTimeInterval];
|
||||||
|
NSTimeInterval elapsedMonotonicTime = (currentMonotonicTime - lastMonotonicUpdateCheckTime);
|
||||||
|
|
||||||
|
if (elapsedMonotonicTime < SUMinimumMonotonicUpdateCheckInterval) {
|
||||||
|
minimumMonotonicEnforcedDelay = (SUMinimumMonotonicUpdateCheckInterval - elapsedMonotonicTime);
|
||||||
|
} else {
|
||||||
|
minimumMonotonicEnforcedDelay = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dateIntervalSinceCheck = wallTimeInterval;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
intervalSinceCheck = 0;
|
// Without using the current date, we assume a full update interval is needed
|
||||||
|
dateIntervalSinceCheck = 0;
|
||||||
|
minimumMonotonicEnforcedDelay = SUMinimumMonotonicUpdateCheckInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updateCheckInterval < SUMinimumUpdateCheckInterval) {
|
||||||
|
updateCheckInterval = SUMinimumUpdateCheckInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we want to figure out how long until we check again.
|
// Now we want to figure out how long until we check again.
|
||||||
if (updateCheckInterval < SUMinimumUpdateCheckInterval)
|
NSTimeInterval wallDelayUntilCheck;
|
||||||
updateCheckInterval = SUMinimumUpdateCheckInterval;
|
if (dateIntervalSinceCheck < updateCheckInterval) {
|
||||||
if (intervalSinceCheck < updateCheckInterval) {
|
// It hasn't been long enough.
|
||||||
NSTimeInterval delayUntilCheck = (updateCheckInterval - intervalSinceCheck); // It hasn't been long enough.
|
wallDelayUntilCheck = (updateCheckInterval - dateIntervalSinceCheck);
|
||||||
if ([self.delegate respondsToSelector:@selector(updater:willScheduleUpdateCheckAfterDelay:)]) {
|
|
||||||
[self.delegate updater:self willScheduleUpdateCheckAfterDelay:delayUntilCheck];
|
|
||||||
}
|
|
||||||
[self.updaterTimer startAndFireAfterDelay:delayUntilCheck];
|
|
||||||
} else {
|
} else {
|
||||||
|
wallDelayUntilCheck = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now compute delay with enforced minimum delay requirement
|
||||||
|
// The minimum delay (based on monotonic clock) is an extra layer of defense to prevent too frequent update checks
|
||||||
|
// in case the wall clock is not working properly (eg from too many system wake events, system date changes, NTP..)
|
||||||
|
NSTimeInterval finalDelayUntilCheck = MAX(wallDelayUntilCheck, minimumMonotonicEnforcedDelay);
|
||||||
|
if (finalDelayUntilCheck <= 0) {
|
||||||
// We're overdue! Run one now.
|
// We're overdue! Run one now.
|
||||||
[self checkForUpdatesInBackground];
|
[self checkForUpdatesInBackground];
|
||||||
|
} else {
|
||||||
|
if ([self.delegate respondsToSelector:@selector(updater:willScheduleUpdateCheckAfterDelay:)]) {
|
||||||
|
[self.delegate updater:self willScheduleUpdateCheckAfterDelay:finalDelayUntilCheck];
|
||||||
|
}
|
||||||
|
[self.updaterTimer startTimerWithWallTimeDelay:wallDelayUntilCheck monotonicTimeDelay:minimumMonotonicEnforcedDelay];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -688,7 +740,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
|||||||
// Ensure the delegate doesn't start a new session when being notified of the previous one ending
|
// Ensure the delegate doesn't start a new session when being notified of the previous one ending
|
||||||
if (!strongSelf.sessionInProgress) {
|
if (!strongSelf.sessionInProgress) {
|
||||||
if (shouldScheduleNextUpdateCheck) {
|
if (shouldScheduleNextUpdateCheck) {
|
||||||
[strongSelf scheduleNextUpdateCheckFiringImmediately:NO usingCurrentTime:NO];
|
[strongSelf scheduleNextUpdateCheckFiringImmediately:NO usingCurrentDate:NO];
|
||||||
} else {
|
} else {
|
||||||
SULog(SULogLevelDefault, @"Disabling scheduled updates..");
|
SULog(SULogLevelDefault, @"Disabling scheduled updates..");
|
||||||
}
|
}
|
||||||
@@ -739,7 +791,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
|||||||
|
|
||||||
// Ensure the delegate doesn't start a new session when being notified of the previous one ending
|
// Ensure the delegate doesn't start a new session when being notified of the previous one ending
|
||||||
if (!strongSelf.sessionInProgress) {
|
if (!strongSelf.sessionInProgress) {
|
||||||
[strongSelf scheduleNextUpdateCheckFiringImmediately:shouldShowUpdateImmediately usingCurrentTime:NO];
|
[strongSelf scheduleNextUpdateCheckFiringImmediately:shouldShowUpdateImmediately usingCurrentDate:NO];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
@@ -784,7 +836,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
|||||||
|
|
||||||
if (!self.sessionInProgress) {
|
if (!self.sessionInProgress) {
|
||||||
[self cancelNextUpdateCycle];
|
[self cancelNextUpdateCycle];
|
||||||
[self scheduleNextUpdateCheckFiringImmediately:NO usingCurrentTime:YES];
|
[self scheduleNextUpdateCheckFiringImmediately:NO usingCurrentDate:YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
@@ -366,7 +366,7 @@ SU_EXPORT extern NSString *const SUSystemProfilerPreferredLanguageKey;
|
|||||||
|
|
||||||
Automatic update checks need to be enabled for this to trigger.
|
Automatic update checks need to be enabled for this to trigger.
|
||||||
|
|
||||||
@param delay The delay in seconds until the next scheduled update will occur.
|
@param delay The delay in seconds until the next scheduled update will occur. This is an approximation and may vary due to system state.
|
||||||
|
|
||||||
@param updater The updater instance.
|
@param updater The updater instance.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Vendored
+1
-1
@@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
- (instancetype)initWithDelegate:(id<SPUUpdaterTimerDelegate>)delegate;
|
- (instancetype)initWithDelegate:(id<SPUUpdaterTimerDelegate>)delegate;
|
||||||
|
|
||||||
- (void)startAndFireAfterDelay:(NSTimeInterval)delay;
|
- (void)startTimerWithWallTimeDelay:(NSTimeInterval)wallDelayUntilCheck monotonicTimeDelay:(NSTimeInterval)minimumEnforcedDelay;
|
||||||
|
|
||||||
- (void)invalidate;
|
- (void)invalidate;
|
||||||
|
|
||||||
|
|||||||
Vendored
+67
-17
@@ -15,14 +15,16 @@
|
|||||||
@interface SPUUpdaterTimer ()
|
@interface SPUUpdaterTimer ()
|
||||||
|
|
||||||
@property (nonatomic, readonly, weak) id<SPUUpdaterTimerDelegate> delegate;
|
@property (nonatomic, readonly, weak) id<SPUUpdaterTimerDelegate> delegate;
|
||||||
@property (nonatomic) dispatch_source_t source;
|
@property (nonatomic) dispatch_source_t wallTimeSource;
|
||||||
|
@property (nonatomic) dispatch_source_t monotonicTimeSource;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SPUUpdaterTimer
|
@implementation SPUUpdaterTimer
|
||||||
|
|
||||||
@synthesize delegate = _delegate;
|
@synthesize delegate = _delegate;
|
||||||
@synthesize source = _source;
|
@synthesize wallTimeSource = _wallTimeSource;
|
||||||
|
@synthesize monotonicTimeSource = _monotonicTimeSource;
|
||||||
|
|
||||||
- (instancetype)initWithDelegate:(id<SPUUpdaterTimerDelegate>)delegate
|
- (instancetype)initWithDelegate:(id<SPUUpdaterTimerDelegate>)delegate
|
||||||
{
|
{
|
||||||
@@ -33,28 +35,76 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)startAndFireAfterDelay:(NSTimeInterval)delay
|
- (void)startTimerWithWallTimeDelay:(NSTimeInterval)wallTimeDelay monotonicTimeDelay:(NSTimeInterval)monotonicTimeDelay
|
||||||
{
|
{
|
||||||
self.source = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
|
|
||||||
|
|
||||||
// We use the wall time instead of cpu time for our dispatch timer
|
|
||||||
// So eg if the computer sleeps we want to include that time spent in our timer
|
|
||||||
dispatch_time_t timeToFire = dispatch_walltime(NULL, (int64_t)(delay * NSEC_PER_SEC));
|
|
||||||
dispatch_source_set_timer(self.source, timeToFire, DISPATCH_TIME_FOREVER, SULeewayUpdateCheckInterval * NSEC_PER_SEC);
|
|
||||||
|
|
||||||
__weak __typeof__(self) weakSelf = self;
|
__weak __typeof__(self) weakSelf = self;
|
||||||
dispatch_source_set_event_handler(self.source, ^{
|
// When timersFired reaches 2, both wall/monotonic timers have been fired, and the delegate is ready to receive the notification
|
||||||
[weakSelf.delegate updaterTimerDidFire];
|
__block uint8_t timersFired = 0;
|
||||||
});
|
|
||||||
|
|
||||||
dispatch_resume(self.source);
|
if (wallTimeDelay <= 0) {
|
||||||
|
timersFired++;
|
||||||
|
self.wallTimeSource = nil;
|
||||||
|
} else {
|
||||||
|
// We use the wall time instead of cpu time for a large date interval
|
||||||
|
// So eg if the computer sleeps we want to include that time spent in our timer
|
||||||
|
self.wallTimeSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
|
||||||
|
|
||||||
|
dispatch_time_t wallTime = dispatch_walltime(NULL, (int64_t)(wallTimeDelay * NSEC_PER_SEC));
|
||||||
|
dispatch_source_set_timer(self.wallTimeSource, wallTime, DISPATCH_TIME_FOREVER, SULeewayWallUpdateCheckInterval * NSEC_PER_SEC);
|
||||||
|
|
||||||
|
dispatch_source_set_event_handler(self.wallTimeSource, ^{
|
||||||
|
timersFired++;
|
||||||
|
if (timersFired > 1) {
|
||||||
|
[weakSelf.delegate updaterTimerDidFire];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (monotonicTimeDelay <= 0) {
|
||||||
|
timersFired++;
|
||||||
|
self.monotonicTimeSource = nil;
|
||||||
|
} else {
|
||||||
|
// We also use monotonic time to enforce a minimum delay interval
|
||||||
|
// This ensures we don't fire the wall clock based timer too frequently if the real clock changes
|
||||||
|
self.monotonicTimeSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
|
||||||
|
|
||||||
|
dispatch_time_t monotonicTime = dispatch_time(DISPATCH_TIME_NOW , (int64_t)(monotonicTimeDelay * NSEC_PER_SEC));
|
||||||
|
dispatch_source_set_timer(self.monotonicTimeSource, monotonicTime, DISPATCH_TIME_FOREVER, SULeewayMonotonicUpdateCheckInterval * NSEC_PER_SEC);
|
||||||
|
|
||||||
|
dispatch_source_set_event_handler(self.monotonicTimeSource, ^{
|
||||||
|
timersFired++;
|
||||||
|
if (timersFired > 1) {
|
||||||
|
[weakSelf.delegate updaterTimerDidFire];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Have both timers already ran? (this should be unlikely)
|
||||||
|
if (timersFired > 1) {
|
||||||
|
[self.delegate updaterTimerDidFire];
|
||||||
|
} else {
|
||||||
|
// Resume available timers
|
||||||
|
|
||||||
|
if (self.wallTimeSource != nil) {
|
||||||
|
dispatch_resume(self.wallTimeSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.monotonicTimeSource != nil) {
|
||||||
|
dispatch_resume(self.monotonicTimeSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)invalidate
|
- (void)invalidate
|
||||||
{
|
{
|
||||||
if (self.source != nil) {
|
if (self.wallTimeSource != nil) {
|
||||||
dispatch_source_cancel(self.source);
|
dispatch_source_cancel(self.wallTimeSource);
|
||||||
self.source = nil;
|
self.wallTimeSource = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.monotonicTimeSource != nil) {
|
||||||
|
dispatch_source_cancel(self.monotonicTimeSource);
|
||||||
|
self.monotonicTimeSource = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+3
-1
@@ -19,7 +19,9 @@
|
|||||||
extern const NSTimeInterval SUDefaultUpdatePermissionPromptInterval;
|
extern const NSTimeInterval SUDefaultUpdatePermissionPromptInterval;
|
||||||
extern const NSTimeInterval SUMinimumUpdateCheckInterval;
|
extern const NSTimeInterval SUMinimumUpdateCheckInterval;
|
||||||
extern const NSTimeInterval SUDefaultUpdateCheckInterval;
|
extern const NSTimeInterval SUDefaultUpdateCheckInterval;
|
||||||
extern const uint64_t SULeewayUpdateCheckInterval;
|
extern const NSTimeInterval SUMinimumMonotonicUpdateCheckInterval;
|
||||||
|
extern const uint64_t SULeewayWallUpdateCheckInterval;
|
||||||
|
extern const uint64_t SULeewayMonotonicUpdateCheckInterval;
|
||||||
extern const NSTimeInterval SUImpatientUpdateCheckInterval;
|
extern const NSTimeInterval SUImpatientUpdateCheckInterval;
|
||||||
|
|
||||||
extern NSString *const SUBundleIdentifier;
|
extern NSString *const SUBundleIdentifier;
|
||||||
|
|||||||
Vendored
+4
-1
@@ -18,8 +18,11 @@
|
|||||||
// Define some minimum intervals to avoid DoS-like checking attacks
|
// Define some minimum intervals to avoid DoS-like checking attacks
|
||||||
const NSTimeInterval SUMinimumUpdateCheckInterval = DEBUG ? 60 : (60 * 60);
|
const NSTimeInterval SUMinimumUpdateCheckInterval = DEBUG ? 60 : (60 * 60);
|
||||||
const NSTimeInterval SUDefaultUpdateCheckInterval = DEBUG ? 60 : (60 * 60 * 24);
|
const NSTimeInterval SUDefaultUpdateCheckInterval = DEBUG ? 60 : (60 * 60 * 24);
|
||||||
|
const NSTimeInterval SUMinimumMonotonicUpdateCheckInterval = DEBUG ? 30 : (60 * 5);
|
||||||
|
|
||||||
// The amount of time the system can defer our update check (for improved performance)
|
// The amount of time the system can defer our update check (for improved performance)
|
||||||
const uint64_t SULeewayUpdateCheckInterval = DEBUG ? 1 : 15;
|
const uint64_t SULeewayWallUpdateCheckInterval = DEBUG ? 1 : 60;
|
||||||
|
const uint64_t SULeewayMonotonicUpdateCheckInterval = DEBUG ? 1 : 5;
|
||||||
|
|
||||||
// If the update has already been automatically downloaded, we normally don't want to bug the user about the update
|
// If the update has already been automatically downloaded, we normally don't want to bug the user about the update
|
||||||
// However if the user has gone a very long time without quitting an application, we will bug them
|
// However if the user has gone a very long time without quitting an application, we will bug them
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ class SUTestApplicationTest: XCTestCase
|
|||||||
func testRegularUpdate()
|
func testRegularUpdate()
|
||||||
{
|
{
|
||||||
let app = XCUIApplication()
|
let app = XCUIApplication()
|
||||||
|
app.launchArguments = [
|
||||||
|
"-AppleLanguages",
|
||||||
|
"(en)"
|
||||||
|
]
|
||||||
app.launch()
|
app.launch()
|
||||||
|
|
||||||
XCTAssertFalse(app.dialogs["alert"].staticTexts["Update succeeded!"].exists, "Update is already installed; please do a clean build")
|
XCTAssertFalse(app.dialogs["alert"].staticTexts["Update succeeded!"].exists, "Update is already installed; please do a clean build")
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func extractVersion(parent: XMLNode) -> String? {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem], newVersions: Set<String>?, maxNewVersionsInFeed: Int, link: String?, newChannel: String?, majorVersion: String?, phasedRolloutInterval: Int?, criticalUpdateVersion: String?, informationalUpdateVersions: [String]?) throws -> (numNewUpdates: Int, numExistingUpdates: Int) {
|
func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem], newVersions: Set<String>?, maxNewVersionsInFeed: Int, fullReleaseNotesLink: String?, link: String?, newChannel: String?, majorVersion: String?, phasedRolloutInterval: Int?, criticalUpdateVersion: String?, informationalUpdateVersions: [String]?) throws -> (numNewUpdates: Int, numExistingUpdates: Int) {
|
||||||
let appBaseName = updates[0].appPath.deletingPathExtension().lastPathComponent
|
let appBaseName = updates[0].appPath.deletingPathExtension().lastPathComponent
|
||||||
|
|
||||||
let sparkleNS = "http://www.andymatuschak.org/xml-namespaces/sparkle"
|
let sparkleNS = "http://www.andymatuschak.org/xml-namespaces/sparkle"
|
||||||
@@ -168,6 +168,12 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem], newVersions: Set
|
|||||||
item.addChild(linkElement)
|
item.addChild(linkElement)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let fullReleaseNotesLink = fullReleaseNotesLink,
|
||||||
|
let fullReleaseNotesElement = XMLElement.element(withName: SUAppcastElementFullReleaseNotesLink, uri: sparkleNS) as? XMLElement {
|
||||||
|
fullReleaseNotesElement.setChildren([text(fullReleaseNotesLink)])
|
||||||
|
item.addChild(fullReleaseNotesElement)
|
||||||
|
}
|
||||||
|
|
||||||
// Set new channel name
|
// Set new channel name
|
||||||
if let newChannelName = newChannel,
|
if let newChannelName = newChannel,
|
||||||
let channelNameElement = XMLElement.element(withName: SUAppcastElementChannel, uri: sparkleNS) as? XMLElement {
|
let channelNameElement = XMLElement.element(withName: SUAppcastElementChannel, uri: sparkleNS) as? XMLElement {
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ struct GenerateAppcast: ParsableCommand {
|
|||||||
@Option(name: .customLong("release-notes-url-prefix"), help: ArgumentHelp("A URL that will be used as prefix for constructing URLs for release notes.", valueName: "url"), transform: { URL(string: $0) })
|
@Option(name: .customLong("release-notes-url-prefix"), help: ArgumentHelp("A URL that will be used as prefix for constructing URLs for release notes.", valueName: "url"), transform: { URL(string: $0) })
|
||||||
var releaseNotesURLPrefix : URL?
|
var releaseNotesURLPrefix : URL?
|
||||||
|
|
||||||
|
@Option(name: .customLong("full-release-notes-url"), help: ArgumentHelp("A URL that will be used for the full release notes.", valueName: "url"))
|
||||||
|
var fullReleaseNotesURL: String?
|
||||||
|
|
||||||
@Option(name: .long, help: ArgumentHelp("A URL to the application's website which Sparkle may use for directing users to if they cannot download a new update from within the application. This will be used for new generated update items. By default, no product link is used.", valueName: "link"))
|
@Option(name: .long, help: ArgumentHelp("A URL to the application's website which Sparkle may use for directing users to if they cannot download a new update from within the application. This will be used for new generated update items. By default, no product link is used.", valueName: "link"))
|
||||||
var link: String?
|
var link: String?
|
||||||
|
|
||||||
@@ -220,7 +223,7 @@ struct GenerateAppcast: ParsableCommand {
|
|||||||
relativeTo: archivesSourceDir)
|
relativeTo: archivesSourceDir)
|
||||||
|
|
||||||
// Write the appcast
|
// Write the appcast
|
||||||
let (numNewUpdates, numExistingUpdates) = try writeAppcast(appcastDestPath: appcastDestPath, updates: updates, newVersions: versions, maxNewVersionsInFeed: maxNewVersionsInFeed, link: link, newChannel: channel, majorVersion: majorVersion, phasedRolloutInterval: phasedRolloutInterval, criticalUpdateVersion: criticalUpdateVersion, informationalUpdateVersions: informationalUpdateVersions)
|
let (numNewUpdates, numExistingUpdates) = try writeAppcast(appcastDestPath: appcastDestPath, updates: updates, newVersions: versions, maxNewVersionsInFeed: maxNewVersionsInFeed, fullReleaseNotesLink: fullReleaseNotesURL, link: link, newChannel: channel, majorVersion: majorVersion, phasedRolloutInterval: phasedRolloutInterval, criticalUpdateVersion: criticalUpdateVersion, informationalUpdateVersions: informationalUpdateVersions)
|
||||||
|
|
||||||
// Inform the user, pluralizing "update" if necessary
|
// Inform the user, pluralizing "update" if necessary
|
||||||
let pluralizeUpdates = { $0 == 1 ? "update" : "updates" }
|
let pluralizeUpdates = { $0 == 1 ? "update" : "updates" }
|
||||||
|
|||||||
Reference in new issue
Block a user