diff --git a/Sparkle/SUAppcast.h b/Sparkle/SUAppcast.h index 8f3efc8e..a035f18f 100644 --- a/Sparkle/SUAppcast.h +++ b/Sparkle/SUAppcast.h @@ -19,6 +19,7 @@ SU_EXPORT @interface SUAppcast : NSObject @property (copy) NSDictionary *httpHeaders; - (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *))err; +- (SUAppcast *)copyWithoutDeltaUpdates; @property (readonly, copy) NSArray *items; @end diff --git a/Sparkle/SUAppcast.m b/Sparkle/SUAppcast.m index dced1da7..2ea651d1 100644 --- a/Sparkle/SUAppcast.m +++ b/Sparkle/SUAppcast.m @@ -287,4 +287,16 @@ return nodes[i]; } +- (SUAppcast *)copyWithoutDeltaUpdates { + SUAppcast *other = [SUAppcast new]; + NSMutableArray *nonDeltaItems = [NSMutableArray new]; + + for(SUAppcastItem *item in self.items) { + if (![item isDeltaUpdate]) [nonDeltaItems addObject:item]; + } + + other.items = nonDeltaItems; + return other; +} + @end diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 4ab61093..71aae39d 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -133,19 +133,26 @@ if ([[self.updater delegate] respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it? { item = [[self.updater delegate] bestValidUpdateInAppcast:ac forUpdater:self.updater]; + if ([item isDeltaUpdate]) { + self.nonDeltaUpdateItem = [[self.updater delegate] bestValidUpdateInAppcast:[ac copyWithoutDeltaUpdates] forUpdater:self.updater]; + } } else // If not, we'll take care of it ourselves. { // Find the first update we can actually use. - NSEnumerator *updateEnumerator = [[ac items] objectEnumerator]; - do { - item = [updateEnumerator nextObject]; - } while (item && ![self hostSupportsItem:item]); + for(SUAppcastItem *i in ac.items) { + if ([self hostSupportsItem:i]) { + item = i; + break; + } + } - SUAppcastItem *deltaUpdateItem = [item deltaUpdates][[self.host version]]; - if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) { - self.nonDeltaUpdateItem = item; - item = deltaUpdateItem; + if (item) { + SUAppcastItem *deltaUpdateItem = [item deltaUpdates][[self.host version]]; + if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) { + self.nonDeltaUpdateItem = item; + item = deltaUpdateItem; + } } }