Permalink
Browse files

Sparkle now finds the newest update in an appcast for which the host …

…meets the minimum system requirements. This fixes bug 228485. Thanks to Stuart Morgan for the patch.
  • Loading branch information...
1 parent 80721a0 commit 1264a6b3a79c0da0d6f860e9ce1d395bb0f45336 @andymatuschak andymatuschak committed May 9, 2008
Showing with 15 additions and 13 deletions.
  1. +0 −1 SUAppcast.h
  2. +0 −8 SUAppcast.m
  3. +15 −4 SUBasicUpdateDriver.m
View
@@ -20,7 +20,6 @@
- (void)setDelegate:delegate;
- (void)setUserAgentString:(NSString *)userAgentString;
-- (SUAppcastItem *)newestItem;
- (NSArray *)items;
@end
View
@@ -22,14 +22,6 @@ - (void)dealloc
[super dealloc];
}
-- (SUAppcastItem *)newestItem
-{
- if ([items count] > 0)
- return [items objectAtIndex:0]; // the RSS class takes care of sorting by published date, descending.
- else
- return nil;
-}
-
- (NSArray *)items
{
return items;
View
@@ -38,7 +38,10 @@ - (BOOL)hostSupportsItem:(SUAppcastItem *)ui
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
{
- return [[[SUUserDefaults standardUserDefaults] objectForKey:SUSkippedVersionKey] isEqualToString:[ui versionString]];
+ NSString *skippedVersion = [[SUUserDefaults standardUserDefaults] objectForKey:SUSkippedVersionKey];
+ if (skippedVersion == nil) { return NO; }
+ return [[SUStandardVersionComparator defaultComparator] compareVersion:[ui versionString]
+ toVersion:skippedVersion] != NSOrderedDescending;
}
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
@@ -48,11 +51,19 @@ - (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
- (void)appcastDidFinishLoading:(SUAppcast *)ac
{
- updateItem = [[ac newestItem] retain];
+ NSArray* updates = [ac items];
+ if ([updates count] > 0)
+ [[SUUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:SULastCheckTimeKey];
+
+ // Find the first update we can actually use.
+ NSEnumerator *updateEnumerator = [updates objectEnumerator];
+ do {
+ updateItem = [updateEnumerator nextObject];
+ } while (updateItem && ![self hostSupportsItem:updateItem]);
+
+ [updateItem retain];
CFRelease(ac); // Remember that we're explicitly managing the memory of the appcast.
if (updateItem == nil) { [self didNotFindUpdate]; return; }
-
- [[SUUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:SULastCheckTimeKey];
if ([self itemContainsValidUpdate:updateItem])
[self didFindValidUpdate];

0 comments on commit 1264a6b

Please sign in to comment.