From 30a72a1bd6480654f3507cd65be1029eeb4fedc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Thu, 17 Dec 2015 22:32:48 +0000 Subject: [PATCH 1/2] Removed old objectEnumerator --- Sparkle/SUBasicUpdateDriver.m | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 4ab61093..2f22b8c7 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -137,15 +137,19 @@ 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; + } } } From 27f00c04b0aa1187f467662e4496aca39251072d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesi=C5=84ski?= Date: Thu, 17 Dec 2015 23:05:09 +0000 Subject: [PATCH 2/2] Ask delegate for non-delta updates Fixes #700 --- Sparkle/SUAppcast.h | 1 + Sparkle/SUAppcast.m | 12 ++++++++++++ Sparkle/SUBasicUpdateDriver.m | 3 +++ 3 files changed, 16 insertions(+) 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 2f22b8c7..71aae39d 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -133,6 +133,9 @@ 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. {