mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-28 05:14:34 +00:00
Refactor finding latest appcast item
This commit is contained in:
1 parent
ebb822af43
commit
79c1141155
2 files changed
+22
-9
No files matched your search
Vendored
+1
@@ -206,6 +206,7 @@
|
||||
} else {
|
||||
// When no updates are found in the appcast, or latest appcast item info
|
||||
// was not provided (i.e, for a background update check)
|
||||
// In the case no info was provided ofr a background check, the error isn't shown anywhere
|
||||
localizedDescription = SULocalizedString(@"Update Error!", nil);
|
||||
recoverySuggestion = SULocalizedString(@"No valid update information could be loaded.", nil);
|
||||
recoveryOption = SULocalizedString(@"Cancel Update", nil);
|
||||
|
||||
Vendored
+21
-9
@@ -199,15 +199,27 @@
|
||||
} else {
|
||||
// Find the latest appcast item even if it fails min/max OS test
|
||||
// We want to inform the user if an update requires a different OS version
|
||||
// We only need to do this if an update is being checked automatically in the background
|
||||
SUAppcastItem *notFoundPrimaryItem = background ? [self retrieveBestAppcastItemFromAppcast:macOSAppcast versionComparator:applicationVersionComparator secondaryUpdate:nil] : nil;
|
||||
|
||||
NSComparisonResult hostToLatestAppcastItemComparisonResult = (notFoundPrimaryItem != nil) ? [applicationVersionComparator compareVersion:self.host.version toVersion:notFoundPrimaryItem.versionString] : 0;
|
||||
|
||||
SUStandardVersionComparator *standardVersionComparator = (notFoundPrimaryItem != nil) ? [[SUStandardVersionComparator alloc] init] : nil;
|
||||
|
||||
BOOL passesMinOSVersion = (notFoundPrimaryItem != nil) ? [[self class] isItemMinimumOperatingSystemVersionOK:notFoundPrimaryItem versionComparator:standardVersionComparator] : YES;
|
||||
BOOL passesMaxOSVersion = (notFoundPrimaryItem != nil) ? [[self class] isItemMaximumOperatingSystemVersionOK:notFoundPrimaryItem versionComparator:standardVersionComparator] : YES;
|
||||
// We only need to do this if an update is being checked by the user manually
|
||||
SUAppcastItem *notFoundPrimaryItem;
|
||||
NSComparisonResult hostToLatestAppcastItemComparisonResult;
|
||||
BOOL passesMinOSVersion;
|
||||
BOOL passesMaxOSVersion;
|
||||
if (!background) {
|
||||
notFoundPrimaryItem = [self retrieveBestAppcastItemFromAppcast:macOSAppcast versionComparator:applicationVersionComparator secondaryUpdate:nil];
|
||||
|
||||
hostToLatestAppcastItemComparisonResult = [applicationVersionComparator compareVersion:self.host.version toVersion:notFoundPrimaryItem.versionString];
|
||||
|
||||
SUStandardVersionComparator *standardVersionComparator = [[SUStandardVersionComparator alloc] init];
|
||||
|
||||
passesMinOSVersion = [[self class] isItemMinimumOperatingSystemVersionOK:notFoundPrimaryItem versionComparator:standardVersionComparator];
|
||||
|
||||
passesMaxOSVersion = [[self class] isItemMaximumOperatingSystemVersionOK:notFoundPrimaryItem versionComparator:standardVersionComparator];
|
||||
} else {
|
||||
notFoundPrimaryItem = nil;
|
||||
hostToLatestAppcastItemComparisonResult = 0;
|
||||
passesMinOSVersion = YES;
|
||||
passesMaxOSVersion = YES;
|
||||
}
|
||||
|
||||
[self.delegate didNotFindUpdateWithLatestAppcastItem:notFoundPrimaryItem hostToLatestAppcastItemComparisonResult:hostToLatestAppcastItemComparisonResult passesMinOSVersion:passesMinOSVersion passesMaxOSVersion:passesMaxOSVersion];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user