Skip to content

Commit

Permalink
Sparkle now finds the newest update in an appcast for which the host …
Browse files Browse the repository at this point in the history
…meets the minimum system requirements. This fixes bug 228485. Thanks to Stuart Morgan for the patch.
  • Loading branch information
andymatuschak committed May 9, 2008
1 parent 80721a0 commit 1264a6b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
1 change: 0 additions & 1 deletion SUAppcast.h
Expand Up @@ -20,7 +20,6 @@
- (void)setDelegate:delegate;
- (void)setUserAgentString:(NSString *)userAgentString;

- (SUAppcastItem *)newestItem;
- (NSArray *)items;

@end
Expand Down
8 changes: 0 additions & 8 deletions SUAppcast.m
Expand Up @@ -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;
Expand Down
19 changes: 15 additions & 4 deletions SUBasicUpdateDriver.m
Expand Up @@ -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
Expand All @@ -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];
Expand Down

0 comments on commit 1264a6b

Please sign in to comment.