Просмотр исходного кода

sparkle-updater: Enable delta update failure fallback

Refer to https://github.com/kc5nra/Sparkle/commit/53cad369538f916ae0f7064231719519166dcbae
for further details
Palana 11 лет назад
Родитель
Сommit
afa172feea
1 измененных файлов с 15 добавлено и 5 удалено
  1. 15 5
      obs/sparkle-updater.mm

+ 15 - 5
obs/sparkle-updater.mm

@@ -19,10 +19,9 @@ static inline bool equali(NSString *a, NSString *b)
 
 @synthesize updateToUndeployed;
 
-- (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast
-				 forUpdater:(SUUpdater *)updater
+- (SUAppcastItem *)bestValidUpdateWithDeltasInAppcast:(SUAppcast *)appcast
+					   forUpdater:(SUUpdater *)updater
 {
-	static SUAppcastItem *selected;
 	SUAppcastItem *item = appcast.items.firstObject;
 	if (!appcast.items.firstObject)
 		return nil;
@@ -56,11 +55,22 @@ static inline bool equali(NSString *a, NSString *b)
 	NSString *url = dict[@"sparkle:releaseNotesLink"];
 	dict[@"sparkle:releaseNotesLink"] = [url stringByAppendingFormat:@"#%@",
 		build];
-	selected = [[SUAppcastItem alloc] initWithDictionary:dict];
 
+	return [[SUAppcastItem alloc] initWithDictionary:dict];
+}
+
+- (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast
+				 forUpdater:(SUUpdater *)updater
+{
+	SUAppcastItem *selected =
+			[self bestValidUpdateWithDeltasInAppcast:appcast
+						      forUpdater:updater];
+
+	NSBundle *host = updater.hostBundle;
+	NSString *build = [host objectForInfoDictionaryKey:@"CFBundleVersion"];
 	SUAppcastItem *deltaUpdate = [selected deltaUpdates][build];
 	if (deltaUpdate)
-		selected = deltaUpdate;
+		return deltaUpdate;
 
 	return selected;
 }