Integrate "Fix #1061 & #835: Sparkle clients polling too frequently"

https://github.com/sparkle-project/Sparkle/pull/1135
This commit is contained in:
Zorg committed 2021-01-16 18:13:58 -08:00
1 parent 32b0ca2e0f
commit 3c0e02f333
1 file changed
+12 -2
+12 -2
View File
@@ -57,6 +57,8 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
@property (nonatomic, copy) void (^preStartedScheduledUpdateBlock)(void);
@property (nonatomic, nullable) id<SPUResumableUpdate> resumableUpdate;
@property (nonatomic, copy) NSDate *updateLastCheckedDate;
@property (nonatomic) BOOL loggedATSWarning;
@property (nonatomic) BOOL loggedDSAWarning;
@@ -78,6 +80,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
@synthesize startedUpdater = _startedUpdater;
@synthesize preStartedScheduledUpdateBlock = _preStartedScheduledUpdateBlock;
@synthesize resumableUpdate = _resumableUpdate;
@synthesize updateLastCheckedDate = _updateLastCheckedDate;
@synthesize loggedATSWarning = _loggedATSWarning;
@synthesize loggedDSAWarning = _loggedDSAWarning;
@@ -324,13 +327,20 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
- (NSDate *)lastUpdateCheckDate
{
return [self.host objectForUserDefaultsKey:SULastCheckTimeKey];
if ([self updateLastCheckedDate] == nil)
{
[self setUpdateLastCheckedDate:[self.host objectForUserDefaultsKey:SULastCheckTimeKey]];
}
return [self updateLastCheckedDate];
}
- (void)updateLastUpdateCheckDate
{
[self willChangeValueForKey:NSStringFromSelector(@selector((lastUpdateCheckDate)))];
[self.host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey];
// 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.host setObject:[self updateLastCheckedDate] forUserDefaultsKey:SULastCheckTimeKey];
[self didChangeValueForKey:NSStringFromSelector(@selector((lastUpdateCheckDate)))];
}