From d75856cfeeda51bfcef6f9f6dcdafe7c921e7713 Mon Sep 17 00:00:00 2001 From: Daniel Jalkut Date: Mon, 27 Jul 2015 15:13:07 -0400 Subject: [PATCH 01/23] Declare informationOnlyUpdate as a property of SUAppcastItem. Declaring a property makes it obvious where changes to the logic about whether an update is "information only" should be made, and leaves the code at the calling point more readable. Instead of inferring that an appast item is information only by the simple omission of a fileURL, require that it also have a infoURL. --- Sparkle/SUAppcastItem.h | 1 + Sparkle/SUAppcastItem.m | 5 +++++ Sparkle/SUUpdateAlert.m | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Sparkle/SUAppcastItem.h b/Sparkle/SUAppcastItem.h index e4c2a06d..86843bfb 100644 --- a/Sparkle/SUAppcastItem.h +++ b/Sparkle/SUAppcastItem.h @@ -32,6 +32,7 @@ SU_EXPORT @interface SUAppcastItem : NSObject @property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate; @property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate; +@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate; // Returns the dictionary provided in initWithDictionary; this might be useful later for extensions. @property (readonly, copy) NSDictionary *propertiesDictionary; diff --git a/Sparkle/SUAppcastItem.m b/Sparkle/SUAppcastItem.m index 2a11f247..67eeee07 100644 --- a/Sparkle/SUAppcastItem.m +++ b/Sparkle/SUAppcastItem.m @@ -55,6 +55,11 @@ return [self.propertiesDictionary[SUAppcastElementTags] containsObject:SUAppcastElementCriticalUpdate]; } +- (BOOL)isInformationOnlyUpdate +{ + return (([self infoURL] != nil) && ([self fileURL] == nil)); +} + - (instancetype)initWithDictionary:(NSDictionary *)dict { return [self initWithDictionary:dict failureReason:nil]; diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index 6338956d..a386c716 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -186,7 +186,7 @@ [self.window setLevel:NSFloatingWindowLevel]; // This means the window will float over all other apps, if our app is switched out ?! } - if ([self.updateItem fileURL] == nil) { + if (self.updateItem.isInformationOnlyUpdate) { [self.installButton setTitle:SULocalizedString(@"Learn More...", @"Alternate title for 'Install Update' button when there's no download in RSS feed.")]; [self.installButton setAction:@selector(openInfoURL:)]; } From f739101b4fcb8c292b38f6938999547f660e621c Mon Sep 17 00:00:00 2001 From: Daniel Jalkut Date: Mon, 27 Jul 2015 15:15:59 -0400 Subject: [PATCH 02/23] Finesse the wording of the message displayed in SUUpdateAlert when the item is "information only." Previously when an information-only update is displayed to the user, it uses the inappropriate text "Would you like to download it now?" Since the alert is modified in this case to provide a 'Learn More' button, then text should match the action that is being offered. In this commit I break the localized string up into parts such that the notice about the updated version is the same in either case, but the action offered differs depending on the type of update being presented. Note that this commit only represents changes to the English Sparkle.strings file. Until and unless localized versions of Sparkle.strings add translations for the new broken-up strings, they will display this information in English only. --- Sparkle/SUUpdateAlert.m | 15 ++++++++++++++- Sparkle/en.lproj/Sparkle.strings | 9 +++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index a386c716..ccfeba58 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -231,7 +231,20 @@ else { [self.versionDisplayer formatVersion:&updateItemVersion andVersion:&hostVersion]; } - return [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to download it now?", nil), [self.host name], updateItemVersion, hostVersion]; + + // We display a slightly different summary depending on if it's an "info-only" item or not + NSString* actionSentence = nil; + + if ([self.updateItem isInformationOnlyUpdate]) + { + actionSentence = SULocalizedString(@"Would you like to learn more about this update on the web?", @"Final portion of descriptionText when the update informational with no download."); + } + else + { + actionSentence = SULocalizedString(@"Would you like to download it now?", @"Final portion of descriptionText when the update is downloadable."); + } + + return [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. %@", @"Description text for SUUpdateAlert. The final placeholder %4$@ will be substituted with one of the two strings below, depending on whether it's an informational or download update."), [self.host name], updateItemVersion, hostVersion, actionSentence]; } - (void)webView:(WebView *)sender didFinishLoadForFrame:frame diff --git a/Sparkle/en.lproj/Sparkle.strings b/Sparkle/en.lproj/Sparkle.strings index 50c54b02..ee8c6cfc 100644 --- a/Sparkle/en.lproj/Sparkle.strings +++ b/Sparkle/en.lproj/Sparkle.strings @@ -6,6 +6,15 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ is currently the newest version available."; +/* Description text for SUUpdateAlert. The final placeholder %4$@ will be substituted with one of the two strings below, depending on whether it's an informational or download update. */ +"%@ %@ is now available--you have %@. %@" = "%1$@ %2$@ is now available--you have %3$@. %4$@"; + +/* Final portion of descriptionText when the update is downloadable. */ +"Would you like to download it now?" = "Would you like to download it now?"; + +/* Final portion of descriptionText when the update informational with no download. */ +"Would you like to learn more about this update on the web?" = "Would you like to learn more about this update on the web?"; + "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ is now available—you have %3$@. Would you like to download it now?"; "%@ downloaded" = "%@ downloaded"; From 831e8fda9fe990be6b6a828f542b5c0a2ec6406e Mon Sep 17 00:00:00 2001 From: Daniel Jalkut Date: Mon, 27 Jul 2015 15:23:16 -0400 Subject: [PATCH 03/23] Remove old localized string which is now superseded by broken-down versions. --- Sparkle/en.lproj/Sparkle.strings | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sparkle/en.lproj/Sparkle.strings b/Sparkle/en.lproj/Sparkle.strings index ee8c6cfc..5dfba567 100644 --- a/Sparkle/en.lproj/Sparkle.strings +++ b/Sparkle/en.lproj/Sparkle.strings @@ -15,8 +15,6 @@ /* Final portion of descriptionText when the update informational with no download. */ "Would you like to learn more about this update on the web?" = "Would you like to learn more about this update on the web?"; -"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ is now available—you have %3$@. Would you like to download it now?"; - "%@ downloaded" = "%@ downloaded"; "%@ of %@" = "%1$@ of %2$@"; From 0418566e4c19a8810dc1979326c254d4f61a6408 Mon Sep 17 00:00:00 2001 From: Daniel Jalkut Date: Mon, 27 Jul 2015 17:26:33 -0400 Subject: [PATCH 04/23] Revisions for style as requested. --- Sparkle/SUAppcastItem.m | 2 +- Sparkle/SUUpdateAlert.m | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Sparkle/SUAppcastItem.m b/Sparkle/SUAppcastItem.m index 67eeee07..7ee42020 100644 --- a/Sparkle/SUAppcastItem.m +++ b/Sparkle/SUAppcastItem.m @@ -57,7 +57,7 @@ - (BOOL)isInformationOnlyUpdate { - return (([self infoURL] != nil) && ([self fileURL] == nil)); + return self.infoURL && !self.fileURL; } - (instancetype)initWithDictionary:(NSDictionary *)dict diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index ccfeba58..6ce7381e 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -232,17 +232,17 @@ [self.versionDisplayer formatVersion:&updateItemVersion andVersion:&hostVersion]; } - // We display a slightly different summary depending on if it's an "info-only" item or not - NSString* actionSentence = nil; + // We display a slightly different summary depending on if it's an "info-only" item or not + NSString *actionSentence = nil; - if ([self.updateItem isInformationOnlyUpdate]) - { - actionSentence = SULocalizedString(@"Would you like to learn more about this update on the web?", @"Final portion of descriptionText when the update informational with no download."); - } - else - { - actionSentence = SULocalizedString(@"Would you like to download it now?", @"Final portion of descriptionText when the update is downloadable."); - } + if (self.updateItem.isInformationOnlyUpdate) + { + actionSentence = SULocalizedString(@"Would you like to learn more about this update on the web?", @"Final portion of descriptionText when the update informational with no download."); + } + else + { + actionSentence = SULocalizedString(@"Would you like to download it now?", @"Final portion of descriptionText when the update is downloadable."); + } return [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. %@", @"Description text for SUUpdateAlert. The final placeholder %4$@ will be substituted with one of the two strings below, depending on whether it's an informational or download update."), [self.host name], updateItemVersion, hostVersion, actionSentence]; } From ee56cea7fdcee6926b510cd98d2bba51e7fc3674 Mon Sep 17 00:00:00 2001 From: Daniel Jalkut Date: Tue, 28 Jul 2015 00:30:10 -0400 Subject: [PATCH 05/23] Revise approach for localizing the "Would you like to learn more about this update on the web?" case. Previously I had broken down the description text into one localizable string for the main clause of the sentence, e.g.: "MyApp 1.1 is available--you have 1.0", and separate localizable strings for the follow-up question about whether to download or get more information. This breakdown didn't work well with some languages e.g. Arabic where the existing localization mixes the placeholder values differently. The new approach is to localize the two complete sentences separately. Unfortunately this means that for the "Would you like to learn more about this update on the web?" case, the localization is missing for all languages except English. But, at least the localization files are properly populated with the expected keys, and await localization updates when possible. I also spotted a few instances in which an outdated version of the existing localization key was being used (with parens instead of --), so there was no localization occurring in those cases. I fixed those by updating the key to match the current status quo. --- Sparkle/ar.lproj/Sparkle.strings | 4 ++++ Sparkle/ca.lproj/Sparkle.strings | 6 +++++- Sparkle/cs.lproj/Sparkle.strings | 4 ++++ Sparkle/da.lproj/Sparkle.strings | 4 ++++ Sparkle/de.lproj/Sparkle.strings | 4 ++++ Sparkle/el.lproj/Sparkle.strings | 4 ++++ Sparkle/en.lproj/Sparkle.strings | 11 ++++------- Sparkle/es.lproj/Sparkle.strings | 4 ++++ Sparkle/fi.lproj/Sparkle.strings | 6 +++++- Sparkle/fr.lproj/Sparkle.strings | 4 ++++ Sparkle/he.lproj/Sparkle.strings | 6 +++++- Sparkle/is.lproj/Sparkle.strings | 4 ++++ Sparkle/it.lproj/Sparkle.strings | 4 ++++ Sparkle/ja.lproj/Sparkle.strings | 4 ++++ Sparkle/ko.lproj/Sparkle.strings | 4 ++++ Sparkle/nb.lproj/Sparkle.strings | 4 ++++ Sparkle/nl.lproj/Sparkle.strings | 4 ++++ Sparkle/pl.lproj/Sparkle.strings | 4 ++++ Sparkle/pt_BR.lproj/Sparkle.strings | 4 ++++ Sparkle/pt_PT.lproj/Sparkle.strings | 4 ++++ Sparkle/ro.lproj/Sparkle.strings | 4 ++++ Sparkle/ru.lproj/Sparkle.strings | 4 ++++ Sparkle/sk.lproj/Sparkle.strings | 4 ++++ Sparkle/sl.lproj/Sparkle.strings | 4 ++++ Sparkle/sv.lproj/Sparkle.strings | 4 ++++ Sparkle/th.lproj/Sparkle.strings | 4 ++++ Sparkle/tr.lproj/Sparkle.strings | 3 +++ Sparkle/uk.lproj/Sparkle.strings | 4 ++++ Sparkle/zh_CN.lproj/Sparkle.strings | 4 ++++ Sparkle/zh_TW.lproj/Sparkle.strings | 4 ++++ 30 files changed, 122 insertions(+), 10 deletions(-) diff --git a/Sparkle/ar.lproj/Sparkle.strings b/Sparkle/ar.lproj/Sparkle.strings index ce77b652..c8f6d535 100644 --- a/Sparkle/ar.lproj/Sparkle.strings +++ b/Sparkle/ar.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "الإصدار %2$@ هو أحدث إصدار متوفر حاليًا لتطبيق %1$@"; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "لديك الإصدار %3$@ من تطبيق %1$@، هل ترغب بتزيل الإصدار %2$@ الآن"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "تم تنزيل %@"; "%@ of %@" = "%1$@ من %2$@"; diff --git a/Sparkle/ca.lproj/Sparkle.strings b/Sparkle/ca.lproj/Sparkle.strings index 2c3eec74..23c3306b 100644 --- a/Sparkle/ca.lproj/Sparkle.strings +++ b/Sparkle/ca.lproj/Sparkle.strings @@ -6,7 +6,11 @@ "%@ %@ is currently the newest version available." = "%@ %@ és la versió disponible més actual."; -"%@ %@ is now available (you have %@). Would you like to download it now?" = "%@ %@ està disponible (ara teniu %@). Voleu actualitzar?"; +/* Description text for SUUpdateAlert when the update is downloadable. */ +"%@ %@ is now available--you have %@. Would you like to download it now?" = "%@ %@ està disponible (ara teniu %@). Voleu actualitzar?"; + +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; "%@ does not have permission to write to the application's directory! Are you running off a disk image? If not, ask your system administrator for help." = "%@ no té permís per escriure al directori d'aplicacions! Esteu executant el programa des d'un disc d'imatge? Si no és així, demaneu ajuda al vostre administrador."; diff --git a/Sparkle/cs.lproj/Sparkle.strings b/Sparkle/cs.lproj/Sparkle.strings index 2ca1b168..0cf3adb4 100644 --- a/Sparkle/cs.lproj/Sparkle.strings +++ b/Sparkle/cs.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ je nejnovější dostupná verze"; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "Je k dispozici %1$@ %2$@ - máte %3$@. Přejete si nyní zkopírovat aktualizaci?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "zkopírováno %@"; "%@ of %@" = "%1$@ z %2$@"; diff --git a/Sparkle/da.lproj/Sparkle.strings b/Sparkle/da.lproj/Sparkle.strings index f098528d..0e18c057 100644 --- a/Sparkle/da.lproj/Sparkle.strings +++ b/Sparkle/da.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ er den aktuelle version."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ er tilgængelig! Du har %3$@. Skal den hentes nu?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ hentet"; "%@ of %@" = "%1$@ af %2$@"; diff --git a/Sparkle/de.lproj/Sparkle.strings b/Sparkle/de.lproj/Sparkle.strings index 05674190..cd3d9b25 100644 --- a/Sparkle/de.lproj/Sparkle.strings +++ b/Sparkle/de.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ ist zur Zeit die neueste verfügbare Version."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ ist verfügbar (Sie verwenden Version %3$@). Möchten Sie die neue Version jetzt herunterladen?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ heruntergeladen"; "%@ of %@" = "%1$@ von %2$@"; diff --git a/Sparkle/el.lproj/Sparkle.strings b/Sparkle/el.lproj/Sparkle.strings index dca6fa5c..150f3e8e 100644 --- a/Sparkle/el.lproj/Sparkle.strings +++ b/Sparkle/el.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "Το %1$@ %2$@ είναι η τελευταία διαθέσιμη έκδοση."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "Το %1$@ %2$@ είναι πλέον διαθέσιμο--έχετε το %3$@. Θέλετε να το κατεβάσετε τώρα;"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ λήφθησαν"; "%@ of %@" = "%1$@ από %2$@"; diff --git a/Sparkle/en.lproj/Sparkle.strings b/Sparkle/en.lproj/Sparkle.strings index 5dfba567..03364442 100644 --- a/Sparkle/en.lproj/Sparkle.strings +++ b/Sparkle/en.lproj/Sparkle.strings @@ -6,14 +6,11 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ is currently the newest version available."; -/* Description text for SUUpdateAlert. The final placeholder %4$@ will be substituted with one of the two strings below, depending on whether it's an informational or download update. */ -"%@ %@ is now available--you have %@. %@" = "%1$@ %2$@ is now available--you have %3$@. %4$@"; +/* Description text for SUUpdateAlert when the update is downloadable. */ +"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to download it now?"; -/* Final portion of descriptionText when the update is downloadable. */ -"Would you like to download it now?" = "Would you like to download it now?"; - -/* Final portion of descriptionText when the update informational with no download. */ -"Would you like to learn more about this update on the web?" = "Would you like to learn more about this update on the web?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; "%@ downloaded" = "%@ downloaded"; diff --git a/Sparkle/es.lproj/Sparkle.strings b/Sparkle/es.lproj/Sparkle.strings index 12eb5b46..490517d7 100644 --- a/Sparkle/es.lproj/Sparkle.strings +++ b/Sparkle/es.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ es la última versión disponible."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ está disponible (usted tiene la %3$@). ¿Desea descargarla ahora?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ descargado"; "%@ of %@" = "%1$@ de %2$@"; diff --git a/Sparkle/fi.lproj/Sparkle.strings b/Sparkle/fi.lproj/Sparkle.strings index 02268cdb..8c412406 100644 --- a/Sparkle/fi.lproj/Sparkle.strings +++ b/Sparkle/fi.lproj/Sparkle.strings @@ -4,7 +4,11 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ on uusin saatavilla oleva versio."; -"%@ %@ is now available (you have %@). Would you like to download it now?" = "%1$@ %2$@ on nyt saatavilla (sinulla on %3$@). Haluatko ladata sen nyt?"; +/* Description text for SUUpdateAlert when the update is downloadable. */ +"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ on nyt saatavilla (sinulla on %3$@). Haluatko ladata sen nyt?"; + +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; "%@ does not have permission to write to the application's directory! Are you running off a disk image? If not, ask your system administrator for help." = "Käyttäjällä %@ ei ole oikeuksia ohjelman kansioon! Ajatko ohjelmaa levytiedostosta? Jos et, kysy apua järjestelmän ylläpitäjältä."; diff --git a/Sparkle/fr.lproj/Sparkle.strings b/Sparkle/fr.lproj/Sparkle.strings index 7ab704c3..229afe0b 100644 --- a/Sparkle/fr.lproj/Sparkle.strings +++ b/Sparkle/fr.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ est la version la plus récente disponible."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ est disponible ; vous utilisez la version %3$@. Voulez-vous le télécharger maintenant ?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ téléchargé"; "%@ of %@" = "%1$@ sur %2$@"; diff --git a/Sparkle/he.lproj/Sparkle.strings b/Sparkle/he.lproj/Sparkle.strings index 7390d3d8..5387d941 100644 --- a/Sparkle/he.lproj/Sparkle.strings +++ b/Sparkle/he.lproj/Sparkle.strings @@ -4,7 +4,11 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ היא הגרסה האחונה הזמינה."; -"%@ %@ is now available (you have %@). Would you like to download it now?" = "%1$@ %2$@ זמין כעת (לך יש %3$@). ברצונך להוריד כעת?"; +/* Description text for SUUpdateAlert when the update is downloadable. */ +"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ זמין כעת (לך יש %3$@). ברצונך להוריד כעת?"; + +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; "%@ does not have permission to write to the application's directory! Are you running off a disk image? If not, ask your system administrator for help." = "ל %@ אין הרשאה לכתוב לתקיית התוכניות! האם אתה פועל מ- disc image? אם לא, בקש עזרה ממנהל הרשת."; diff --git a/Sparkle/is.lproj/Sparkle.strings b/Sparkle/is.lproj/Sparkle.strings index 2ba44113..ccd94d63 100644 --- a/Sparkle/is.lproj/Sparkle.strings +++ b/Sparkle/is.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%@ %@ er nýjasta útgáfan sem er fáanleg þessa stundina."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "Útgafa %2$@ af %1$@ er nú fáanlegt en þú ert með %3$@. Viltu sækja hana núna?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ does not have permission to write to the application's directory! Are you running off a disk image? If not, ask your system administrator for help." = "%@ hefur ekki heimild til að skrifa í möppu forritsins! Ertu að keyra forritið af diskmynd? Ef ekki skaltu ráðfæra þig við kerfisstjórann."; "A new version of %@ has been installed!" = "Ný útgáfa af %@ hefur verið sett inn!"; diff --git a/Sparkle/it.lproj/Sparkle.strings b/Sparkle/it.lproj/Sparkle.strings index 096e6caa..19fe027f 100644 --- a/Sparkle/it.lproj/Sparkle.strings +++ b/Sparkle/it.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ è la versione più recente attualmente disponibile."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ è disponbile; disponi della versione %3$@. Desideri eseguire l’aggiornamento ora?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ scaricato"; "%@ of %@" = "%1$@ di %2$@"; diff --git a/Sparkle/ja.lproj/Sparkle.strings b/Sparkle/ja.lproj/Sparkle.strings index dfe98bee..4241828b 100644 --- a/Sparkle/ja.lproj/Sparkle.strings +++ b/Sparkle/ja.lproj/Sparkle.strings @@ -6,8 +6,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ は現在入手できる最新バージョンです。"; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ が入手できます(使用中のバージョンは %3$@ です)。今すぐダウンロードしますか?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ ダウンロード済み"; "%@ of %@" = "%1$@ / %2$@"; diff --git a/Sparkle/ko.lproj/Sparkle.strings b/Sparkle/ko.lproj/Sparkle.strings index 5d908b7e..2a816bac 100644 --- a/Sparkle/ko.lproj/Sparkle.strings +++ b/Sparkle/ko.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@이(가) 현재 최신 버전입니다."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@이(가) 업데이트 되었습니다. (현재 버전 : %3$@) 다운로드 하시겠습니까?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ 다운로드 완료"; "%@ of %@" = "%1$@ / %2$@"; diff --git a/Sparkle/nb.lproj/Sparkle.strings b/Sparkle/nb.lproj/Sparkle.strings index db8a6c36..6e954ee3 100644 --- a/Sparkle/nb.lproj/Sparkle.strings +++ b/Sparkle/nb.lproj/Sparkle.strings @@ -6,8 +6,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ er nyeste versjon."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ er nå tilgjengelig—du har %3$@. Ønsker du å laste ned og installere nå?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ lastet ned"; "%@ of %@" = "%1$@ av %2$@"; diff --git a/Sparkle/nl.lproj/Sparkle.strings b/Sparkle/nl.lproj/Sparkle.strings index ffa3f0b8..e8d710dc 100644 --- a/Sparkle/nl.lproj/Sparkle.strings +++ b/Sparkle/nl.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ is momenteel de recentste versie."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ is nu beschikbaar—u heeft %3$@. Wilt u het nu downloaden?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ gedownload"; "%@ of %@" = "%1$@ van %2$@"; diff --git a/Sparkle/pl.lproj/Sparkle.strings b/Sparkle/pl.lproj/Sparkle.strings index 953bf45f..003065b0 100644 --- a/Sparkle/pl.lproj/Sparkle.strings +++ b/Sparkle/pl.lproj/Sparkle.strings @@ -6,8 +6,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ jest najbardziej aktualną dostępną wersją."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ jest już dostępny (aktualnie posiadasz %3$@). Chciałbyś go teraz pobrać?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "Pobrano %@"; "%@ of %@" = "%1$@ z %2$@"; diff --git a/Sparkle/pt_BR.lproj/Sparkle.strings b/Sparkle/pt_BR.lproj/Sparkle.strings index a911f9ca..73e8bb04 100755 --- a/Sparkle/pt_BR.lproj/Sparkle.strings +++ b/Sparkle/pt_BR.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ é a versão mais recente disponível."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ está disponível – sua versão é %3$@. Deseja transferi-lo agora?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ transferidos"; "%@ of %@" = "%1$@ de %2$@"; diff --git a/Sparkle/pt_PT.lproj/Sparkle.strings b/Sparkle/pt_PT.lproj/Sparkle.strings index 725628cd..251523f6 100644 --- a/Sparkle/pt_PT.lproj/Sparkle.strings +++ b/Sparkle/pt_PT.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "O %1$@ %2$@ é neste momento a versão mais recente disponível."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "O %1$@ %2$@ está agora disponível e tem a versão %3$@. Gostaria de o transferir agora?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ transferido"; "%@ of %@" = "%1$@ de %2$@"; diff --git a/Sparkle/ro.lproj/Sparkle.strings b/Sparkle/ro.lproj/Sparkle.strings index 648000f7..ff6b8be0 100644 --- a/Sparkle/ro.lproj/Sparkle.strings +++ b/Sparkle/ro.lproj/Sparkle.strings @@ -8,8 +8,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ este cea ultima versiune disponibilă."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ este disponibilă—tu ai %3$@. Dorești să o descărcarci acum?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ descărcat"; "%@ of %@" = "%1$@ din %2$@"; diff --git a/Sparkle/ru.lproj/Sparkle.strings b/Sparkle/ru.lproj/Sparkle.strings index 80ba0f6c..1261f77c 100644 --- a/Sparkle/ru.lproj/Sparkle.strings +++ b/Sparkle/ru.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "В настоящий момент %1$@ %2$@ является новейшей версией."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ теперь доступен – вы имеете %3$@. Хотите загрузить его сейчас?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ загружено"; "%@ of %@" = "%1$@ из %2$@"; diff --git a/Sparkle/sk.lproj/Sparkle.strings b/Sparkle/sk.lproj/Sparkle.strings index 7d5760b9..ef017bae 100644 --- a/Sparkle/sk.lproj/Sparkle.strings +++ b/Sparkle/sk.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@\nje najnovšia dostupná verzia."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "Je dostupná aplikácia %1$@ %2$@ — máte %3$@. Chcete ju prevziať teraz?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ prevzaté"; "%@ of %@" = "%1$@ z %2$@"; diff --git a/Sparkle/sl.lproj/Sparkle.strings b/Sparkle/sl.lproj/Sparkle.strings index 13d790b0..97a627e4 100644 --- a/Sparkle/sl.lproj/Sparkle.strings +++ b/Sparkle/sl.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ je najnovejša verzija programa."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "Na voljo je %1$@ %2$@ — vi imate %3$@. Ga želite prenesti s spleta sedaj?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "prenešenih je %@"; "%@ of %@" = "%1$@ od %2$@"; diff --git a/Sparkle/sv.lproj/Sparkle.strings b/Sparkle/sv.lproj/Sparkle.strings index ab47f40a..83acaf50 100644 --- a/Sparkle/sv.lproj/Sparkle.strings +++ b/Sparkle/sv.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ är för närvarande den senaste tillgängliga versionen."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ finns nu tillgänglig—du har %3$@. Vill hämta uppdateringen nu?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ hämtat"; "%@ of %@" = "%1$@ av %2$@"; diff --git a/Sparkle/th.lproj/Sparkle.strings b/Sparkle/th.lproj/Sparkle.strings index e58bdaef..193483f4 100644 --- a/Sparkle/th.lproj/Sparkle.strings +++ b/Sparkle/th.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ เป็นเวอร์ชั่นใหม่ล่าสุดแล้ว"; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ พร้อมให้ดาวน์โหลดแล้ว (คุณมีเวอร์ชั่น %3$@) ต้องการดาวน์โหลดเลยหรือไม่"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "ดาวน์โหลด %@ เสร็จสิ้น"; "%@ of %@" = "%1$@ จาก %2$@"; diff --git a/Sparkle/tr.lproj/Sparkle.strings b/Sparkle/tr.lproj/Sparkle.strings index 73072cdc..fda03413 100644 --- a/Sparkle/tr.lproj/Sparkle.strings +++ b/Sparkle/tr.lproj/Sparkle.strings @@ -12,8 +12,11 @@ /* de_DE v0.1 - No comment provided by engineer. */ +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ çıktı (Kullandığınız Sürüm: %3$@). Şimdi yeni sürümü indirmek ister misiniz?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; "%@ downloaded" = "%@ indirildi"; diff --git a/Sparkle/uk.lproj/Sparkle.strings b/Sparkle/uk.lproj/Sparkle.strings index 63c3812f..9a3a7d15 100644 --- a/Sparkle/uk.lproj/Sparkle.strings +++ b/Sparkle/uk.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "У данний момент %1$@ %2$@ є останньою версією."; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ доступна – ви маєте %3$@. Бажаєте завантажити її зараз?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ завантажено"; "%@ of %@" = "%1$@ із %2$@"; diff --git a/Sparkle/zh_CN.lproj/Sparkle.strings b/Sparkle/zh_CN.lproj/Sparkle.strings index 091ac8cb..f9027041 100644 --- a/Sparkle/zh_CN.lproj/Sparkle.strings +++ b/Sparkle/zh_CN.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ 是当前的最新版本。"; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ 已经可供下载—你现在的版本是 %3$@。您要现在下载它吗?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ 已下载"; "%@ of %@" = "%1$@ / %2$@"; diff --git a/Sparkle/zh_TW.lproj/Sparkle.strings b/Sparkle/zh_TW.lproj/Sparkle.strings index 8f67b4f9..459ef76b 100644 --- a/Sparkle/zh_TW.lproj/Sparkle.strings +++ b/Sparkle/zh_TW.lproj/Sparkle.strings @@ -4,8 +4,12 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ 已是目前最新的版本。"; +/* Description text for SUUpdateAlert when the update is downloadable. */ "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ 現在已可取得,您的版本則是 %3$@。您要現在下載嗎?"; +/* Description text for SUUpdateAlert when the update informational with no download. */ +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; + "%@ downloaded" = "%@ 已下載"; "%@ of %@" = "%1$@ / %2$@"; From 99ac9eaf7c8b20f8b44e1353968267e7c5c37fe2 Mon Sep 17 00:00:00 2001 From: Daniel Jalkut Date: Tue, 28 Jul 2015 00:37:48 -0400 Subject: [PATCH 06/23] Update string formulation to use the new separated localized strings for each case. Also update the code formatting a bit to be at least a little internally consistent. Switch to using dot notation within this method. --- Sparkle/SUUpdateAlert.m | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index 6ce7381e..e5aba794 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -223,28 +223,22 @@ NSString *updateItemVersion = [self.updateItem displayVersionString]; NSString *hostVersion = [self.host displayVersion]; // Display more info if the version strings are the same; useful for betas. - if (!self.versionDisplayer && [updateItemVersion isEqualToString:hostVersion] ) - { + if (!self.versionDisplayer && [updateItemVersion isEqualToString:hostVersion] ) { updateItemVersion = [updateItemVersion stringByAppendingFormat:@" (%@)", [self.updateItem versionString]]; - hostVersion = [hostVersion stringByAppendingFormat:@" (%@)", [self.host version]]; - } - else { + hostVersion = [hostVersion stringByAppendingFormat:@" (%@)", self.host.version]; + } else { [self.versionDisplayer formatVersion:&updateItemVersion andVersion:&hostVersion]; } // We display a slightly different summary depending on if it's an "info-only" item or not - NSString *actionSentence = nil; + NSString *finalString = nil; - if (self.updateItem.isInformationOnlyUpdate) - { - actionSentence = SULocalizedString(@"Would you like to learn more about this update on the web?", @"Final portion of descriptionText when the update informational with no download."); + if (self.updateItem.isInformationOnlyUpdate) { + finalString = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?", @"Description text for SUUpdateAlert when the update informational with no download."), self.host.name, updateItemVersion, hostVersion]; + } else { + finalString = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to download it now?", @"Description text for SUUpdateAlert when the update is downloadable."), self.host.name, updateItemVersion, hostVersion]; } - else - { - actionSentence = SULocalizedString(@"Would you like to download it now?", @"Final portion of descriptionText when the update is downloadable."); - } - - return [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. %@", @"Description text for SUUpdateAlert. The final placeholder %4$@ will be substituted with one of the two strings below, depending on whether it's an informational or download update."), [self.host name], updateItemVersion, hostVersion, actionSentence]; + return finalString; } - (void)webView:(WebView *)sender didFinishLoadForFrame:frame From abdeade019b8e8f765a0c169b97523c51a554bb3 Mon Sep 17 00:00:00 2001 From: Daniel Jalkut Date: Tue, 28 Jul 2015 00:41:24 -0400 Subject: [PATCH 07/23] =?UTF-8?q?Put=20back=20some=20"=E2=80=94"=20charact?= =?UTF-8?q?ers=20that=20had=20shifted=20to=20"--"=20in=20the=20mix.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sparkle/en.lproj/Sparkle.strings | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sparkle/en.lproj/Sparkle.strings b/Sparkle/en.lproj/Sparkle.strings index 03364442..35d29205 100644 --- a/Sparkle/en.lproj/Sparkle.strings +++ b/Sparkle/en.lproj/Sparkle.strings @@ -7,10 +7,10 @@ "%@ %@ is currently the newest version available." = "%1$@ %2$@ is currently the newest version available."; /* Description text for SUUpdateAlert when the update is downloadable. */ -"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to download it now?"; +"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ is now available—you have %3$@. Would you like to download it now?"; /* Description text for SUUpdateAlert when the update informational with no download. */ -"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available—you have %3$@. Would you like to learn more about this update on the web?"; "%@ downloaded" = "%@ downloaded"; From 06876e723f42cf08f4cb97f4261f360ff74e47d8 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Sat, 15 Aug 2015 16:53:04 -0700 Subject: [PATCH 08/23] Exclude build directory from Coveralls. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ffd8ae3b..6219756e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,4 @@ before_install: - pip install cpp-coveralls - pyenv rehash script: make ci -after_success: coveralls --gcov-options '\-lp' +after_success: coveralls --exclude build --gcov-options '\-lp' From 2e226f65ac452273c84e53f2f7baca1f21dd8317 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Sat, 15 Aug 2015 17:08:19 -0700 Subject: [PATCH 09/23] Try xcode-coveralls instead. --- .travis.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6219756e..ac318fab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,6 @@ language: objective-c before_install: - brew update - - brew list pyenv || brew install pyenv - - eval "$(pyenv init -)" - - pyenv install 2.7.6 - - pyenv global 2.7.6 - - pyenv rehash - - pip install cpp-coveralls - - pyenv rehash + - brew install macmade/tap/xcode-coveralls script: make ci -after_success: coveralls --exclude build --gcov-options '\-lp' +after_success: xcode-coveralls --exclude Tests --exclude Vendor build/Build/Intermediates/Sparkle.build/Coverage/Sparkle.build/Objects-normal/x86_64 From 9f674f65471348c323c2553a08a263d53c216ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Sun, 16 Aug 2015 01:14:49 +0100 Subject: [PATCH 10/23] Updated Polish translation --- Sparkle/pl.lproj/Sparkle.strings | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Sparkle/pl.lproj/Sparkle.strings b/Sparkle/pl.lproj/Sparkle.strings index 953bf45f..25cdfc63 100644 --- a/Sparkle/pl.lproj/Sparkle.strings +++ b/Sparkle/pl.lproj/Sparkle.strings @@ -1,12 +1,12 @@ /* "%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?"; */ -"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ został pobrany i jest gotowy do użycia! Czy chciałbyś teraz zainstalować i ponownie uruchomić %1$@?"; +"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ został pobrany i jest gotowy do użycia! Czy chcesz teraz zainstalować i ponownie uruchomić %1$@?"; /* "%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again."; */ -"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "%1$@ nie może zostać zaktualizowany gdy jest uruchomiony z woluminu tylko do odczytu w stylu obraz dysku lub napęd optyczny. Przenieś %1$@ do teczki Programy, uruchom z nowej lokalizacji i spróbuj ponownie."; +"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "%1$@ nie może zostać zaktualizowany gdy jest uruchomiony z woluminu tylko do odczytu jak obraz dysku lub napęd optyczny. Przenieś %1$@ do folderu Programy, uruchom z nowej lokacji i spróbuj ponownie."; -"%@ %@ is currently the newest version available." = "%1$@ %2$@ jest najbardziej aktualną dostępną wersją."; +"%@ %@ is currently the newest version available." = "%1$@ %2$@ jest najnowszą dostępną wersją."; -"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ jest już dostępny (aktualnie posiadasz %3$@). Chciałbyś go teraz pobrać?"; +"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ jest już dostępny (aktualnie posiadasz %3$@). Czy chcesz go teraz pobrać?"; "%@ downloaded" = "Pobrano %@"; @@ -24,7 +24,7 @@ "An error occurred while installing the update. Please try again later." = "Błąd podczas instalowania uaktualnienia. Spróbuj ponownie później"; -"An error occurred while parsing the update feed." = "Błąd podczas analizowania danych o uaktualnieniu."; +"An error occurred while parsing the update feed." = "Błąd podczas wczytywania danych o uaktualnieniu."; "An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@." = "Błąd podczas ponownego uruchomienia %1$@, ale nowa wersja będzie dostępna przy ponownym ręcznym uruchomieniu %1$@."; @@ -38,10 +38,10 @@ "Checking for updates..." = "Sprawdzam uaktualnienia…"; /* Take care not to overflow the status window. */ -"Downloading update..." = "Pobieram uaktualnienia…"; +"Downloading update..." = "Pobieram uaktualnienie…"; /* Take care not to overflow the status window. */ -"Extracting update..." = "Rozpakowuję uaktualnienia…"; +"Extracting update..." = "Rozpakowuję uaktualnienie…"; /* the unit for gigabytes */ "GB" = "GB"; @@ -61,7 +61,7 @@ "Ready to Install" = "Gotowy do instalacji"; -"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = "Czy %1$@ powinien automatycznie sprawdzać uaktualnienia? Zawsze możesz to samemu sprawdzić z menu %1$@."; +"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = "Czy %1$@ ma automatycznie sprawdzać uaktualnienia? Zawsze możesz ręcznie sprawdzać z menu %1$@."; "Update Error!" = "Błąd uaktualniania!"; @@ -70,4 +70,3 @@ "You already have the newest version of %@." = "Posiadasz najnowszą wersję %@."; "You're up-to-date!" = "Jesteś na bieżąco!"; - From 0a840f11dafb39a070e1dfd62950e0bb948eb832 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Sat, 15 Aug 2015 17:17:12 -0700 Subject: [PATCH 11/23] Exclude /Applications - coveralls is tracking headers from the OS X SDK. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ac318fab..084559ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,4 @@ before_install: - brew update - brew install macmade/tap/xcode-coveralls script: make ci -after_success: xcode-coveralls --exclude Tests --exclude Vendor build/Build/Intermediates/Sparkle.build/Coverage/Sparkle.build/Objects-normal/x86_64 +after_success: xcode-coveralls --exclude /Applications --exclude Tests --exclude Vendor build/Build/Intermediates/Sparkle.build/Coverage/Sparkle.build/Objects-normal/x86_64 From f63e606600035517c50c6b566f6c4e61f945cc13 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Mon, 17 Aug 2015 23:53:30 -0700 Subject: [PATCH 12/23] Set LD_RUNPATH_SEARCH_PATHS in Podspec. Closes #598 --- Sparkle.podspec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sparkle.podspec b/Sparkle.podspec index e4aaf773..5e256552 100644 --- a/Sparkle.podspec +++ b/Sparkle.podspec @@ -21,6 +21,9 @@ Pod::Spec.new do |s| s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h' s.vendored_framework = 'Sparkle.framework' s.resources = 'Sparkle.framework' - s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}/Sparkle"' } + s.xcconfig = { + 'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}/Sparkle"', + 'LD_RUNPATH_SEARCH_PATHS' => '@loader_path/../Frameworks' + } s.requires_arc = true end From 3c583db3da6410dfafb0aaf72b66eec365155f46 Mon Sep 17 00:00:00 2001 From: Zorg Date: Tue, 18 Aug 2015 23:31:26 -0400 Subject: [PATCH 13/23] Deprecate serving over http without DSA This deprecates only using Apple's code signing for validation. See issue #543 --- Sparkle/SUUpdater.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index 5e0557f0..73ebafea 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -111,6 +111,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults BOOL hasPublicDSAKey = [host publicDSAKey] != nil; BOOL isMainBundle = [bundle isEqualTo:[NSBundle mainBundle]]; BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned]; + BOOL servingOverHttps = [[[[self feedURL] scheme] lowercaseString] isEqualToString:@"https"]; if (!isMainBundle && !hasPublicDSAKey) { [self notifyWillShowModalAlert]; NSAlert *alert = [[NSAlert alloc] init]; @@ -125,6 +126,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults alert.informativeText = @"For security reasons, you need to code sign your application or sign your updates with a DSA key. See Sparkle's documentation for more information."; [alert runModal]; [self notifyDidShowModalAlert]; + } else if (isMainBundle && !hasPublicDSAKey && !servingOverHttps) { + SULog(@"WARNING: Serving updates over http without signing them with a DSA key is deprecated and may not be possible in a future release. Please serve your updates over https, or sign them with a DSA key, or do both. See Sparkle's documentation for more information."); } // This runs the permission prompt if needed, but never before the app has finished launching because the runloop won't run before that From 3d3372b485e008088acd9d4e33c6bca32be71dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LIU=20Dongyuan=20/=20=E6=9F=B3=E4=B8=9C=E5=8E=9F?= Date: Sat, 22 Aug 2015 12:46:11 -0700 Subject: [PATCH 14/23] Update zh_CN translation --- Sparkle/zh_CN.lproj/Sparkle.strings | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Sparkle/zh_CN.lproj/Sparkle.strings b/Sparkle/zh_CN.lproj/Sparkle.strings index 091ac8cb..903f419c 100644 --- a/Sparkle/zh_CN.lproj/Sparkle.strings +++ b/Sparkle/zh_CN.lproj/Sparkle.strings @@ -1,10 +1,10 @@ -"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ 已下载完毕并可以使用!您想要现在安装 %1$@ 吗?"; +"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ 已下载完毕并可以使用!您想要现在安装 %1$@ 吗?"; -"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "%1$@ 不能被更新,当它运行于一个只读性宗卷如磁盘映像、软盘等上面时。移动 %1$@ 到应用程序文件夹并再试一次。"; +"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "无法更新 %1$@,因为它运行于一个只读宗卷如磁盘映像或光盘。移动 %1$@ 到应用程序文件夹并再试一次。"; "%@ %@ is currently the newest version available." = "%1$@ %2$@ 是当前的最新版本。"; -"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ 已经可供下载—你现在的版本是 %3$@。您要现在下载它吗?"; +"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ 可供下载,您现在的版本是 %3$@。要现在下载吗?"; "%@ downloaded" = "%@ 已下载"; @@ -14,17 +14,17 @@ "A new version of %@ is ready to install!" = "新版本的 %@ 可以安装了!"; -"An error occurred in retrieving update information. Please try again later." = "接收升级信息时出现错误。请稍后再试。"; +"An error occurred in retrieving update information. Please try again later." = "获取升级信息时出现错误,请稍后再试。"; -"An error occurred while downloading the update. Please try again later." = "下载过程中出现错误。请稍后再试。"; +"An error occurred while downloading the update. Please try again later." = "下载过程中出现错误,请稍后再试。"; -"An error occurred while extracting the archive. Please try again later." = "提取过程中出现错误。请稍后再试。"; +"An error occurred while extracting the archive. Please try again later." = "解压过程中出现错误,请稍后再试。"; -"An error occurred while installing the update. Please try again later." = "安装更新的过程中出现错误。请稍后再试。"; +"An error occurred while installing the update. Please try again later." = "安装更新的过程中出现错误,请稍后再试。"; -"An error occurred while parsing the update feed." = "在分析更新流语法时出现错误。请稍后再试。"; +"An error occurred while parsing the update feed." = "解析更新信息时出现错误,请稍后再试。"; -"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@." = "重新启动 %1$@ 时发生了一个错误,但在您下次运行 %1$@ 时新版本将可使用。"; +"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@." = "重新启动 %1$@ 时出现错误,但在下次运行 %1$@ 时新版本将可使用。"; /* the unit for bytes */ "B" = "B"; @@ -33,18 +33,18 @@ "Cancel Update" = "取消更新"; -"Checking for updates..." = "正在核查更新…"; +"Checking for updates..." = "正在检查更新…"; /* Take care not to overflow the status window. */ "Downloading update..." = "正在下载更新…"; /* Take care not to overflow the status window. */ -"Extracting update..." = "正在抽出更新…"; +"Extracting update..." = "正在解压更新…"; /* the unit for gigabytes */ "GB" = "GB"; -"Install and Relaunch" = "安装并重新启动"; +"Install and Relaunch" = "安装并重启应用"; /* Take care not to overflow the status window. */ "Installing update..." = "正在安装更新…"; @@ -59,7 +59,7 @@ "Ready to Install" = "可以开始安装了"; -"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = "您想让 %1$@ 在启动时自动检查更新么?您也可以在程序菜单 %1$@ 中进行手动检查。"; +"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = "您想让 %1$@ 在启动时自动检查更新么?您也可以在程序菜单 %1$@ 中手动检查。"; "Update Error!" = "更新错误!"; @@ -67,7 +67,7 @@ "You already have the newest version of %@." = "您已经在使用最新版本的 %@。"; -"You're up-to-date!" = "你使用的就是最新版!"; +"You're up-to-date!" = "您使用的就是最新版!"; /* Alternative name for "Install" button if we have a paid update or other update without a download but with a URL. */ From 47c2bf31d42105f9eac8a13d8dc66d492e70d67d Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Sun, 23 Aug 2015 10:34:36 +0900 Subject: [PATCH 15/23] Fix German localization Add spaces before ellipses in German localization --- Sparkle/de.lproj/Sparkle.strings | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sparkle/de.lproj/Sparkle.strings b/Sparkle/de.lproj/Sparkle.strings index 05674190..5d8b7114 100644 --- a/Sparkle/de.lproj/Sparkle.strings +++ b/Sparkle/de.lproj/Sparkle.strings @@ -33,13 +33,13 @@ "Cancel Update" = "Aktualisierung abbrechen"; -"Checking for updates..." = "Suche nach Aktualisierungen…"; +"Checking for updates..." = "Suche nach Aktualisierungen …"; /* Take care not to overflow the status window. */ -"Downloading update..." = "Aktualisierung wird heruntergeladen…"; +"Downloading update..." = "Aktualisierung wird heruntergeladen …"; /* Take care not to overflow the status window. */ -"Extracting update..." = "Aktualisierung entpacken…"; +"Extracting update..." = "Aktualisierung entpacken …"; /* the unit for gigabytes */ "GB" = "GB"; @@ -47,7 +47,7 @@ "Install and Relaunch" = "Installieren und erneut starten"; /* Take care not to overflow the status window. */ -"Installing update..." = "Aktualisierung installieren…"; +"Installing update..." = "Aktualisierung installieren …"; /* the unit for kilobytes */ "KB" = "KB"; @@ -72,4 +72,4 @@ /* Alternative name for "Install" button if we have a paid update or other update without a download but with a URL. */ -"Learn More..." = "Mehr über…"; +"Learn More..." = "Mehr über …"; From 43f246d33f93cb5d2276673626c3f65a070021ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Mon, 24 Aug 2015 22:39:15 +0100 Subject: [PATCH 16/23] Updated changelog, version --- CHANGELOG | 20 ++++++++++++++++++++ Configurations/ConfigCommon.xcconfig | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 97b5f3be..bc315db1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,23 @@ +# 1.12.0 + +* Deprecated serving over http without DSA (Zorg) +* Removed extensions from shell scripts (Jake Petroules) +* Improved Autoupdate application (Zorg) + * Do all the installation work after the runloop is set up + * TerminationListener only does termination listening now + * Handle cases where host path is not installation path and host path is not desired executable path +* Set LD_RUNPATH_SEARCH_PATHS in Podspec. (Jake Petroules) +* Updated layout constraints when removing release notes (Zorg) +* Fix German localization (1024jp) +* Updated zh_CN translation (LIU Dongyuan / 柳东原) +* Updated Mac models list until July 2015 (Gabriel Ulici) +* Updated Xcode project languages for which we have translations (Jake Petroules) +* Use NSByteCountFormatter if available (Jake Petroules) +* Declared protocols on SUUpdateAlert for the 10.11 SDK (Daniel Jalkut) +* Silenced warning about casting away const-ness and -Wassign-enum (Daniel Jalkut) +* Rewritten test app so it works again, and from a local web server (Zorg) +* Added script to generate a report comparing the Sparkle.strings files (Kevin Wojniak) + # 1.11.0 * Big improvements to code signing and DSA verification diff --git a/Configurations/ConfigCommon.xcconfig b/Configurations/ConfigCommon.xcconfig index b8e6a447..1f17de6b 100644 --- a/Configurations/ConfigCommon.xcconfig +++ b/Configurations/ConfigCommon.xcconfig @@ -15,7 +15,7 @@ SPARKLE_AUTOMATED_DOWNGRADES = 0 SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0 SPARKLE_VERSION_MAJOR = 1 -SPARKLE_VERSION_MINOR = 11 +SPARKLE_VERSION_MINOR = 12 SPARKLE_VERSION_PATCH = 0 SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH) From 115974650520665fb9510839251fe9ec0952b27f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Thu, 3 Sep 2015 00:06:13 +0100 Subject: [PATCH 17/23] Polish translation update --- Sparkle/pl.lproj/Sparkle.strings | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sparkle/pl.lproj/Sparkle.strings b/Sparkle/pl.lproj/Sparkle.strings index ac6ff5e5..064047e3 100644 --- a/Sparkle/pl.lproj/Sparkle.strings +++ b/Sparkle/pl.lproj/Sparkle.strings @@ -2,14 +2,14 @@ "%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ został pobrany i jest gotowy do użycia! Czy chcesz teraz zainstalować i ponownie uruchomić %1$@?"; /* "%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again."; */ -"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "%1$@ nie może zostać zaktualizowany gdy jest uruchomiony z woluminu tylko do odczytu jak obraz dysku lub napęd optyczny. Przenieś %1$@ do folderu Programy, uruchom z nowej lokacji i spróbuj ponownie."; +"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "%1$@ nie może zostać uaktualniony gdy jest uruchomiony z woluminu tylko do odczytu jak obraz dysku lub napęd optyczny. Przenieś %1$@ do folderu Programy, uruchom z nowej lokacji i spróbuj ponownie."; "%@ %@ is currently the newest version available." = "%1$@ %2$@ jest najnowszą dostępną wersją."; "%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ jest już dostępny (aktualnie posiadasz %3$@). Czy chcesz go teraz pobrać?"; /* Description text for SUUpdateAlert when the update informational with no download. */ -"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ is now available--you have %3$@. Would you like to learn more about this update on the web?"; +"%@ %@ is now available--you have %@. Would you like to learn more about this update on the web?" = "%1$@ %2$@ jest już dostępny (aktualnie posiadasz %3$@). Czy chcesz otworzyć stronę z informacjami o tym uaktualnieniu?"; "%@ downloaded" = "Pobrano %@"; From c78070c7482b49cec8739fdd1d7e27ff6fdded07 Mon Sep 17 00:00:00 2001 From: Zorg Date: Wed, 2 Sep 2015 21:09:11 -0400 Subject: [PATCH 18/23] Improve BinaryDelta error handling & logging * Fix issue #608. From the framework, the error is logged via SULog. From the tool, the error is logged to stderr. Uses NSError handling for both. * Move patch version validation for creating a binary diff into the BinaryDelta tool * Add parameter assertions to createBinaryDelta and handle if -getFileSystemRepresentation:maxLength: fails --- Sparkle/SUBinaryDeltaApply.h | 2 +- Sparkle/SUBinaryDeltaApply.m | 98 +++++++++++++++++-------- Sparkle/SUBinaryDeltaCommon.m | 4 +- Sparkle/SUBinaryDeltaCreate.h | 2 +- Sparkle/SUBinaryDeltaCreate.m | 114 ++++++++++++++++++++---------- Sparkle/SUBinaryDeltaTool.m | 66 +++++++++++------ Sparkle/SUBinaryDeltaUnarchiver.m | 7 +- Tests/SUBinaryDeltaTest.m | 33 ++++----- 8 files changed, 213 insertions(+), 113 deletions(-) diff --git a/Sparkle/SUBinaryDeltaApply.h b/Sparkle/SUBinaryDeltaApply.h index 293c1e11..8390d9c0 100644 --- a/Sparkle/SUBinaryDeltaApply.h +++ b/Sparkle/SUBinaryDeltaApply.h @@ -10,6 +10,6 @@ #define SUBINARYDELTAAPPLY_H @class NSString; -int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose); +BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose, NSError * __autoreleasing *error); #endif diff --git a/Sparkle/SUBinaryDeltaApply.m b/Sparkle/SUBinaryDeltaApply.m index d8eef104..68c61c6c 100644 --- a/Sparkle/SUBinaryDeltaApply.m +++ b/Sparkle/SUBinaryDeltaApply.m @@ -25,12 +25,14 @@ static BOOL applyBinaryDeltaToFile(xar_t x, xar_file_t file, NSString *sourceFil return success; } -int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose) +BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, BOOL verbose, NSError * __autoreleasing *error) { xar_t x = xar_open([patchFile fileSystemRepresentation], READ); if (!x) { - fprintf(stderr, "Unable to open %s. Giving up.\n", [patchFile fileSystemRepresentation]); - return 1; + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to open %@. Giving up.", patchFile] }]; + } + return NO; } SUBinaryDeltaMajorVersion majorDiffVersion = FIRST_DELTA_DIFF_MAJOR_VERSION; @@ -80,13 +82,17 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil } if (majorDiffVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) { - fprintf(stderr, "Unable to identify diff-version %u in delta. Giving up.\n", majorDiffVersion); - return 1; + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to identify diff-version %u in delta. Giving up.", majorDiffVersion] }]; + } + return NO; } if (majorDiffVersion > LATEST_DELTA_DIFF_MAJOR_VERSION) { - fprintf(stderr, "A later version is needed to apply this patch (on major version %u, but patch requests version %u).\n", LATEST_DELTA_DIFF_MAJOR_VERSION, majorDiffVersion); - return 1; + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"A later version is needed to apply this patch (on major version %u, but patch requests version %u).", LATEST_DELTA_DIFF_MAJOR_VERSION, majorDiffVersion] }]; + } + return NO; } BOOL usesNewTreeHash = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion); @@ -95,8 +101,10 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil NSString *expectedAfterHash = usesNewTreeHash ? expectedNewAfterHash : expectedAfterHashv1; if (!expectedBeforeHash || !expectedAfterHash) { - fprintf(stderr, "Unable to find before-sha1 or after-sha1 metadata in delta. Giving up.\n"); - return 1; + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadCorruptFileError userInfo:@{ NSLocalizedDescriptionKey: @"Unable to find before-sha1 or after-sha1 metadata in delta. Giving up." }]; + } + return NO; } if (verbose) { @@ -106,13 +114,19 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil NSString *beforeHash = hashOfTreeWithVersion(source, majorDiffVersion); if (!beforeHash) { - fprintf(stderr, "\nUnable to calculate hash of tree %s\n", [source fileSystemRepresentation]); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to calculate hash of tree %@", source] }]; + } + return NO; } if (![beforeHash isEqualToString:expectedBeforeHash]) { - fprintf(stderr, "\nSource doesn't have expected hash (%s != %s). Giving up.\n", [expectedBeforeHash UTF8String], [beforeHash UTF8String]); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source doesn't have expected hash (%@ != %@). Giving up.", expectedBeforeHash, beforeHash] }]; + } + return NO; } if (verbose) { @@ -120,12 +134,18 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil } if (!removeTree(destination)) { - fprintf(stderr, "\nFailed to remove %s\n", [destination fileSystemRepresentation]); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove %@", destination] }]; + } + return NO; } if (!copyTree(source, destination)) { - fprintf(stderr, "\nFailed to copy %s to %s\n", [source fileSystemRepresentation], [destination fileSystemRepresentation]); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to copy %@ to %@", source, destination] }]; + } + return NO; } BOOL hasExtractKeyAvailable = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion); @@ -149,8 +169,11 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil if (!xar_prop_get(file, DELETE_KEY, &value) || (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_THEN_EXTRACT_OLD_KEY, &value))) { if (!removeTree(destinationFilePath)) { - fprintf(stderr, "\n%s or %s: failed to remove %s\n", DELETE_KEY, DELETE_THEN_EXTRACT_OLD_KEY, [destination fileSystemRepresentation]); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"%@ or %@: failed to remove %@", @DELETE_KEY, @DELETE_THEN_EXTRACT_OLD_KEY, destination] }]; + } + return NO; } if (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_KEY, &value)) { if (verbose) { @@ -164,8 +187,11 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil if (!xar_prop_get(file, BINARY_DELTA_KEY, &value)) { if (!applyBinaryDeltaToFile(x, file, sourceFilePath, destinationFilePath)) { - fprintf(stderr, "\nUnable to patch %s to destination %s\n", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation]); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to patch %@ to destination %@", sourceFilePath, destinationFilePath] }]; + } + return NO; } if (verbose) { @@ -175,8 +201,11 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil (!hasExtractKeyAvailable && xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value))) { // extract and permission modifications don't coexist if (xar_extract_tofile(x, file, [destinationFilePath fileSystemRepresentation]) != 0) { - fprintf(stderr, "\nUnable to extract file to %s\n", [destinationFilePath fileSystemRepresentation]); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to extract file to %@", destinationFilePath] }]; + } + return NO; } if (verbose) { @@ -193,8 +222,11 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil if (!xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value)) { mode_t mode = (mode_t)[[NSString stringWithUTF8String:value] intValue]; if (!modifyPermissions(destinationFilePath, mode)) { - fprintf(stderr, "\nUnable to modify permissions (%s) on file %s\n", value, [destinationFilePath fileSystemRepresentation]); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to modify permissions (%@) on file %@", @(value), destinationFilePath] }]; + } + return NO; } if (verbose) { @@ -209,18 +241,24 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil } NSString *afterHash = hashOfTreeWithVersion(destination, majorDiffVersion); if (!afterHash) { - fprintf(stderr, "\nUnable to calculate hash of tree %s\n", [destination fileSystemRepresentation]); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to calculate hash of tree %@", destination] }]; + } + return NO; } if (![afterHash isEqualToString:expectedAfterHash]) { - fprintf(stderr, "\nDestination doesn't have expected hash (%s != %s). Giving up.\n", [expectedAfterHash UTF8String], [afterHash UTF8String]); + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination doesn't have expected hash (%@ != %@). Giving up.", expectedAfterHash, afterHash] }]; + } removeTree(destination); - return 1; + return NO; } if (verbose) { fprintf(stderr, "\nDone!\n"); } - return 0; + return YES; } diff --git a/Sparkle/SUBinaryDeltaCommon.m b/Sparkle/SUBinaryDeltaCommon.m index a6ecd0be..7395c0e6 100644 --- a/Sparkle/SUBinaryDeltaCommon.m +++ b/Sparkle/SUBinaryDeltaCommon.m @@ -145,7 +145,9 @@ NSData *hashOfFileContents(FTSENT *ent) NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion) { char pathBuffer[PATH_MAX] = {0}; - [path getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]; + if (![path getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) { + return nil; + } char * const sourcePaths[] = {pathBuffer, 0}; FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles); diff --git a/Sparkle/SUBinaryDeltaCreate.h b/Sparkle/SUBinaryDeltaCreate.h index 4afc2281..7111b503 100644 --- a/Sparkle/SUBinaryDeltaCreate.h +++ b/Sparkle/SUBinaryDeltaCreate.h @@ -12,6 +12,6 @@ #import "SUBinaryDeltaCommon.h" @class NSString; -int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose); +BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose, NSError * __autoreleasing *error); #endif diff --git a/Sparkle/SUBinaryDeltaCreate.m b/Sparkle/SUBinaryDeltaCreate.m index de192506..02b5ef53 100644 --- a/Sparkle/SUBinaryDeltaCreate.m +++ b/Sparkle/SUBinaryDeltaCreate.m @@ -221,30 +221,32 @@ static BOOL shouldChangePermissions(NSDictionary *originalInfo, NSDictionary *ne return YES; } -int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose) +BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchFile, SUBinaryDeltaMajorVersion majorVersion, BOOL verbose, NSError * __autoreleasing *error) { - if (majorVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) { - fprintf(stderr, "Version provided (%u) is not valid\n", majorVersion); - return 1; - } - - if (majorVersion > LATEST_DELTA_DIFF_MAJOR_VERSION) { - fprintf(stderr, "This program is too old to create a version %u patch, or the version number provided is invalid\n", majorVersion); - return 1; - } + assert(source); + assert(destination); + assert(patchFile); + assert(majorVersion >= FIRST_DELTA_DIFF_MAJOR_VERSION && majorVersion <= LATEST_DELTA_DIFF_MAJOR_VERSION); SUBinaryDeltaMinorVersion minorVersion = latestMinorVersionForMajorVersion(majorVersion); NSMutableDictionary *originalTreeState = [NSMutableDictionary dictionary]; char pathBuffer[PATH_MAX] = {0}; - [source getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]; + if (![source getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve file system path representation from source %@", source] }]; + } + return NO; + } char *sourcePaths[] = {pathBuffer, 0}; FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles); if (!fts) { - perror("fts_open"); - return 1; + if (error != NULL) { + *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"fts_open failed on source: %@", @(strerror(errno))] }]; + } + return NO; } if (verbose) { @@ -265,19 +267,28 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi NSDictionary *info = infoForFile(ent); if (!info) { - fprintf(stderr, "\nFailed to retrieve info for file %s\n", ent->fts_path); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve info for file %@", @(ent->fts_path)] }]; + } + return NO; } originalTreeState[key] = info; if (aclExists(ent)) { - fprintf(stderr, "\nDiffing ACLs are not supported. Detected ACL in before-tree on file %s\n", ent->fts_path); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing ACLs are not supported. Detected ACL in before-tree on file %@", @(ent->fts_path)] }]; + } + return NO; } if (codeSignatureExtendedAttributeExists(ent)) { - fprintf(stderr, "\nDiffing code signed extended attributes are not supported. Detected extended attribute in before-tree on file %s\n", ent->fts_path); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing code signed extended attributes are not supported. Detected extended attribute in before-tree on file %@", @(ent->fts_path)] }]; + } + return NO; } } fts_close(fts); @@ -285,8 +296,11 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi NSString *beforeHash = hashOfTreeWithVersion(source, majorVersion); if (!beforeHash) { - fprintf(stderr, "\nFailed to generate hash for tree %s\n", [source fileSystemRepresentation]); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to generate hash for tree %@", source] }]; + } + return NO; } NSMutableDictionary *newTreeState = [NSMutableDictionary dictionary]; @@ -300,13 +314,21 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi } pathBuffer[0] = 0; - [destination getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]; + if (![destination getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) { + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve file system path representation from destination %@", destination] }]; + } + return NO; + } sourcePaths[0] = pathBuffer; fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles); if (!fts) { - perror("fts_open"); - return 1; + if (error != NULL) { + *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"fts_open failed on destination: %@", @(strerror(errno))] }]; + } + return NO; } @@ -322,8 +344,11 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi NSDictionary *info = infoForFile(ent); if (!info) { - fprintf(stderr, "\nFailed to retrieve info from file %s\n", ent->fts_path); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve info from file %@", @(ent->fts_path)] }]; + } + return NO; } // We should validate permissions and ACLs even if we don't store the info in the diff in the case of ACLs, @@ -334,18 +359,27 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi mode_t permissions = [info[INFO_PERMISSIONS_KEY] unsignedShortValue]; if (!IS_VALID_PERMISSIONS(permissions)) { - fprintf(stderr, "\nInvalid file permissions after-tree on file %s\nOnly permissions with modes 0755 and 0644 are supported\n", ent->fts_path); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Invalid file permissions after-tree on file %@ (only permissions with modes 0755 and 0644 are supported)", @(ent->fts_path)] }]; + } + return NO; } if (aclExists(ent)) { - fprintf(stderr, "\nDiffing ACLs are not supported. Detected ACL in after-tree on file %s\n", ent->fts_path); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing ACLs are not supported. Detected ACL in after-tree on file %@", @(ent->fts_path)] }]; + } + return NO; } if (codeSignatureExtendedAttributeExists(ent)) { - fprintf(stderr, "\nDiffing code signed extended attributes are not supported. Detected extended attribute in after-tree on file %s\n", ent->fts_path); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing code signed extended attributes are not supported. Detected extended attribute in after-tree on file %@", @(ent->fts_path)] }]; + } + return NO; } NSDictionary *oldInfo = originalTreeState[key]; @@ -372,8 +406,11 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi NSString *afterHash = hashOfTreeWithVersion(destination, majorVersion); if (!afterHash) { - fprintf(stderr, "\nFailed to generate hash for tree %s\n", [destination fileSystemRepresentation]); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to generate hash for tree %@", destination] }]; + } + return NO; } if (verbose) { @@ -479,8 +516,11 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi for (CreateBinaryDeltaOperation *operation in deltaOperations) { NSString *resultPath = [operation resultPath]; if (!resultPath) { - fprintf(stderr, "\nFailed to create patch from source %s and destination %s\n", [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]); - return 1; + if (verbose) fprintf(stderr, "\n"); + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create patch from source %@ and destination %@", operation.relativePath, resultPath] }]; + } + return NO; } if (verbose) { @@ -511,5 +551,5 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi fprintf(stderr, "\nDone!\n"); } - return 0; + return YES; } diff --git a/Sparkle/SUBinaryDeltaTool.m b/Sparkle/SUBinaryDeltaTool.m index 804663dd..01f07dcf 100644 --- a/Sparkle/SUBinaryDeltaTool.m +++ b/Sparkle/SUBinaryDeltaTool.m @@ -28,11 +28,11 @@ static void printUsage(NSString *programName) fprintf(stderr, "%s version []\n", [programName UTF8String]); } -static int runCreateCommand(NSString *programName, NSArray *args) +static BOOL runCreateCommand(NSString *programName, NSArray *args) { if (args.count < 3 || args.count > 5) { printUsage(programName); - return 1; + return NO; } NSUInteger numberOflagsFound = 0; @@ -54,7 +54,7 @@ static int runCreateCommand(NSString *programName, NSArray *args) if (args.count - numberOflagsFound < 3) { printUsage(programName); - return 1; + return NO; } BOOL verbose = (verboseIndex != NSNotFound); @@ -65,7 +65,7 @@ static int runCreateCommand(NSString *programName, NSArray *args) versionComponents = [versionField componentsSeparatedByString:@"="]; if (versionComponents.count != 2) { printUsage(programName); - return 1; + return NO; } } @@ -73,6 +73,16 @@ static int runCreateCommand(NSString *programName, NSArray *args) !versionComponents ? LATEST_DELTA_DIFF_MAJOR_VERSION : (SUBinaryDeltaMajorVersion)[[versionComponents[1] componentsSeparatedByString:@"."][0] intValue]; // ignore minor version if provided + + if (patchVersion < FIRST_DELTA_DIFF_MAJOR_VERSION) { + fprintf(stderr, "Version provided (%u) is not valid\n", patchVersion); + return NO; + } + + if (patchVersion > LATEST_DELTA_DIFF_MAJOR_VERSION) { + fprintf(stderr, "This program is too old to create a version %u patch, or the version number provided is invalid\n", patchVersion); + return NO; + } NSMutableArray *fileArgs = [NSMutableArray array]; for (NSString *argument in args) { @@ -83,37 +93,43 @@ static int runCreateCommand(NSString *programName, NSArray *args) if (fileArgs.count != 3) { printUsage(programName); - return 1; + return NO; } BOOL isDirectory; if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[0] isDirectory:&isDirectory] || !isDirectory) { printUsage(programName); fprintf(stderr, "Error: before-tree must be a directory\n"); - return 1; + return NO; } if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[1] isDirectory:&isDirectory] || !isDirectory) { printUsage(programName); fprintf(stderr, "Error: after-tree must be a directory\n"); - return 1; + return NO; } - return createBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], patchVersion, verbose); + NSError *createDiffError = nil; + if (!createBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], patchVersion, verbose, &createDiffError)) { + fprintf(stderr, "%s\n", [createDiffError.localizedDescription UTF8String]); + return NO; + } + + return YES; } -static int runApplyCommand(NSString *programName, NSArray *args) +static BOOL runApplyCommand(NSString *programName, NSArray *args) { if (args.count < 3 || args.count > 4) { printUsage(programName); - return 1; + return NO; } BOOL verbose = [args containsObject:VERBOSE_FLAG]; if (args.count == 4 && !verbose) { printUsage(programName); - return 1; + return NO; } NSMutableArray *fileArgs = [NSMutableArray array]; @@ -125,30 +141,36 @@ static int runApplyCommand(NSString *programName, NSArray *args) if (fileArgs.count != 3) { printUsage(programName); - return 1; + return NO; } BOOL isDirectory; if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[0] isDirectory:&isDirectory] || !isDirectory) { printUsage(programName); fprintf(stderr, "Error: before-tree must be a directory\n"); - return 1; + return NO; } if (![[NSFileManager defaultManager] fileExistsAtPath:fileArgs[2] isDirectory:&isDirectory] || isDirectory) { printUsage(programName); fprintf(stderr, "Error: patch-file must be a file %d\n", isDirectory); - return 1; + return NO; } - return applyBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], verbose); + NSError *applyDiffError = nil; + if (!applyBinaryDelta(fileArgs[0], fileArgs[1], fileArgs[2], verbose, &applyDiffError)) { + fprintf(stderr, "%s\n", [applyDiffError.localizedDescription UTF8String]); + return NO; + } + + return YES; } -static int runVersionCommand(NSString *programName, NSArray *args) +static BOOL runVersionCommand(NSString *programName, NSArray *args) { if (args.count > 1) { printUsage(programName); - return 1; + return NO; } if (args.count == 0) { @@ -158,7 +180,7 @@ static int runVersionCommand(NSString *programName, NSArray *args) xar_t x = xar_open([patchFile fileSystemRepresentation], READ); if (!x) { fprintf(stderr, "Unable to open patch %s\n", [patchFile fileSystemRepresentation]); - return 1; + return NO; } SUBinaryDeltaMajorVersion majorDiffVersion = FIRST_DELTA_DIFF_MAJOR_VERSION; @@ -184,7 +206,7 @@ static int runVersionCommand(NSString *programName, NSArray *args) fprintf(stdout, "%u.%u\n", majorDiffVersion, minorDiffVersion); } - return 0; + return YES; } int main(int __unused argc, char __unused *argv[]) @@ -201,7 +223,7 @@ int main(int __unused argc, char __unused *argv[]) NSString *command = args[1]; NSArray *commandArguments = [args subarrayWithRange:NSMakeRange(2, args.count - 2)]; - int result; + BOOL result; if ([command isEqualToString:CREATE_COMMAND]) { result = runCreateCommand(programName, commandArguments); } else if ([command isEqualToString:APPLY_COMMAND]) { @@ -209,10 +231,10 @@ int main(int __unused argc, char __unused *argv[]) } else if ([command isEqualToString:VERSION_COMMAND] || [command isEqualToString:VERSION_ALTERNATE_COMMAND]) { result = runVersionCommand(programName, commandArguments); } else { - result = 1; + result = NO; printUsage(programName); } - return result; + return result ? 0 : 1; } } diff --git a/Sparkle/SUBinaryDeltaUnarchiver.m b/Sparkle/SUBinaryDeltaUnarchiver.m index 0c238df7..769131d4 100644 --- a/Sparkle/SUBinaryDeltaUnarchiver.m +++ b/Sparkle/SUBinaryDeltaUnarchiver.m @@ -11,6 +11,7 @@ #import "SUBinaryDeltaApply.h" #import "SUUnarchiver_Private.h" #import "SUHost.h" +#import "SULog.h" #import "NTSynchronousTask.h" @implementation SUBinaryDeltaUnarchiver @@ -26,13 +27,15 @@ NSString *sourcePath = self.updateHostBundlePath; NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]]; - int result = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO); - if (!result) { + NSError *applyDiffError = nil; + BOOL success = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO, &applyDiffError); + if (success) { dispatch_async(dispatch_get_main_queue(), ^{ [self notifyDelegateOfSuccess]; }); } else { + SULog(@"Applying delta patch failed with error: %@", applyDiffError); dispatch_async(dispatch_get_main_queue(), ^{ [self notifyDelegateOfFailure]; }); diff --git a/Tests/SUBinaryDeltaTest.m b/Tests/SUBinaryDeltaTest.m index 2a73c87e..550f55e3 100644 --- a/Tests/SUBinaryDeltaTest.m +++ b/Tests/SUBinaryDeltaTest.m @@ -58,14 +58,23 @@ typedef void (^SUDeltaHandler)(NSFileManager *fileManager, NSString *sourceDirec beforeDiffHandler(fileManager, sourceDirectory, destinationDirectory); } - BOOL createdDiff = - (createBinaryDelta(sourceDirectory, destinationDirectory, diffFile, majorVersion, NO) == 0); - - if (createdDiff && afterDiffHandler != nil) { + NSError *createDiffError = nil; + BOOL createdDiff = createBinaryDelta(sourceDirectory, destinationDirectory, diffFile, majorVersion, NO, &createDiffError); + if (!createdDiff) { + NSLog(@"Creating binary diff failed with error: %@", createDiffError); + } else if (afterDiffHandler != nil) { afterDiffHandler(fileManager, sourceDirectory, destinationDirectory); } - BOOL appliedDiff = (createdDiff && applyBinaryDelta(sourceDirectory, patchDirectory, diffFile, NO) == 0); + NSError *applyDiffError = nil; + BOOL appliedDiff = NO; + if (createdDiff) { + if (applyBinaryDelta(sourceDirectory, patchDirectory, diffFile, NO, &applyDiffError)) { + appliedDiff = YES; + } else { + NSLog(@"Applying binary diff failed with error: %@", applyDiffError); + } + } XCTAssertTrue([fileManager removeItemAtPath:sourceDirectory error:nil]); XCTAssertTrue([fileManager removeItemAtPath:destinationDirectory error:nil]); @@ -107,20 +116,6 @@ typedef void (^SUDeltaHandler)(NSFileManager *fileManager, NSString *sourceDirec }]; } -- (void)testNoFilesDiffWithInvalidLowVersion -{ - XCTAssertFalse([self createAndApplyPatchUsingVersion:(SUBinaryDeltaMajorVersion)0 beforeDiffHandler:^(NSFileManager *__unused fileManager, NSString *sourceDirectory, NSString *destinationDirectory) { - XCTAssertTrue([self testDirectoryHashEqualityWithSource:sourceDirectory destination:destinationDirectory]); - } afterDiffHandler:nil]); -} - -- (void)testNoFilesDiffWithInvalidHighVersion -{ - XCTAssertFalse([self createAndApplyPatchUsingVersion:(SUBinaryDeltaMajorVersion)9999 beforeDiffHandler:^(NSFileManager *__unused fileManager, NSString *sourceDirectory, NSString *destinationDirectory) { - XCTAssertTrue([self testDirectoryHashEqualityWithSource:sourceDirectory destination:destinationDirectory]); - } afterDiffHandler:nil]); -} - - (void)testEmptyDataDiff { [self createAndApplyPatchWithHandler:^(NSFileManager *__unused fileManager, NSString *sourceDirectory, NSString *destinationDirectory) { From b79d71793307fcf9612837af6b90917d718f3149 Mon Sep 17 00:00:00 2001 From: Zorg Date: Wed, 2 Sep 2015 21:35:13 -0400 Subject: [PATCH 19/23] Fix Indentation --- Sparkle/SUBinaryDeltaUnarchiver.m | 34 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Sparkle/SUBinaryDeltaUnarchiver.m b/Sparkle/SUBinaryDeltaUnarchiver.m index 769131d4..7d1e1496 100644 --- a/Sparkle/SUBinaryDeltaUnarchiver.m +++ b/Sparkle/SUBinaryDeltaUnarchiver.m @@ -18,41 +18,41 @@ + (BOOL)canUnarchivePath:(NSString *)path { - return [[path pathExtension] isEqualToString:@"delta"]; + return [[path pathExtension] isEqualToString:@"delta"]; } - (void)applyBinaryDelta { - @autoreleasepool { + @autoreleasepool { NSString *sourcePath = self.updateHostBundlePath; NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]]; NSError *applyDiffError = nil; BOOL success = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO, &applyDiffError); - if (success) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self notifyDelegateOfSuccess]; - }); - } - else { + if (success) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self notifyDelegateOfSuccess]; + }); + } + else { SULog(@"Applying delta patch failed with error: %@", applyDiffError); - dispatch_async(dispatch_get_main_queue(), ^{ - [self notifyDelegateOfFailure]; - }); - } - } + dispatch_async(dispatch_get_main_queue(), ^{ + [self notifyDelegateOfFailure]; + }); + } + } } - (void)start { - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - [self applyBinaryDelta]; - }); + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + [self applyBinaryDelta]; + }); } + (void)load { - [self registerImplementation:self]; + [self registerImplementation:self]; } @end From 309aa157ab2f363690468d7a26b29d270f740303 Mon Sep 17 00:00:00 2001 From: Zorg Date: Wed, 2 Sep 2015 21:39:49 -0400 Subject: [PATCH 20/23] No if one-liners --- Sparkle/SUBinaryDeltaApply.m | 40 +++++++++++++++++++++++-------- Sparkle/SUBinaryDeltaCreate.m | 44 ++++++++++++++++++++++++++--------- 2 files changed, 63 insertions(+), 21 deletions(-) diff --git a/Sparkle/SUBinaryDeltaApply.m b/Sparkle/SUBinaryDeltaApply.m index 68c61c6c..63abdb4f 100644 --- a/Sparkle/SUBinaryDeltaApply.m +++ b/Sparkle/SUBinaryDeltaApply.m @@ -114,7 +114,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi NSString *beforeHash = hashOfTreeWithVersion(source, majorDiffVersion); if (!beforeHash) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to calculate hash of tree %@", source] }]; } @@ -122,7 +124,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi } if (![beforeHash isEqualToString:expectedBeforeHash]) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source doesn't have expected hash (%@ != %@). Giving up.", expectedBeforeHash, beforeHash] }]; } @@ -134,14 +138,18 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi } if (!removeTree(destination)) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove %@", destination] }]; } return NO; } if (!copyTree(source, destination)) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to copy %@ to %@", source, destination] }]; } @@ -169,7 +177,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi if (!xar_prop_get(file, DELETE_KEY, &value) || (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_THEN_EXTRACT_OLD_KEY, &value))) { if (!removeTree(destinationFilePath)) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"%@ or %@: failed to remove %@", @DELETE_KEY, @DELETE_THEN_EXTRACT_OLD_KEY, destination] }]; } @@ -187,7 +197,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi if (!xar_prop_get(file, BINARY_DELTA_KEY, &value)) { if (!applyBinaryDeltaToFile(x, file, sourceFilePath, destinationFilePath)) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to patch %@ to destination %@", sourceFilePath, destinationFilePath] }]; } @@ -201,7 +213,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi (!hasExtractKeyAvailable && xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value))) { // extract and permission modifications don't coexist if (xar_extract_tofile(x, file, [destinationFilePath fileSystemRepresentation]) != 0) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to extract file to %@", destinationFilePath] }]; } @@ -222,7 +236,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi if (!xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value)) { mode_t mode = (mode_t)[[NSString stringWithUTF8String:value] intValue]; if (!modifyPermissions(destinationFilePath, mode)) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to modify permissions (%@) on file %@", @(value), destinationFilePath] }]; } @@ -241,7 +257,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi } NSString *afterHash = hashOfTreeWithVersion(destination, majorDiffVersion); if (!afterHash) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Unable to calculate hash of tree %@", destination] }]; } @@ -249,7 +267,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi } if (![afterHash isEqualToString:expectedAfterHash]) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination doesn't have expected hash (%@ != %@). Giving up.", expectedAfterHash, afterHash] }]; } diff --git a/Sparkle/SUBinaryDeltaCreate.m b/Sparkle/SUBinaryDeltaCreate.m index 02b5ef53..db790642 100644 --- a/Sparkle/SUBinaryDeltaCreate.m +++ b/Sparkle/SUBinaryDeltaCreate.m @@ -267,7 +267,9 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF NSDictionary *info = infoForFile(ent); if (!info) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve info for file %@", @(ent->fts_path)] }]; } @@ -276,7 +278,9 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF originalTreeState[key] = info; if (aclExists(ent)) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing ACLs are not supported. Detected ACL in before-tree on file %@", @(ent->fts_path)] }]; } @@ -284,7 +288,9 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF } if (codeSignatureExtendedAttributeExists(ent)) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing code signed extended attributes are not supported. Detected extended attribute in before-tree on file %@", @(ent->fts_path)] }]; } @@ -296,7 +302,9 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF NSString *beforeHash = hashOfTreeWithVersion(source, majorVersion); if (!beforeHash) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to generate hash for tree %@", source] }]; } @@ -315,7 +323,9 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF pathBuffer[0] = 0; if (![destination getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)]) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve file system path representation from destination %@", destination] }]; } @@ -344,7 +354,9 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF NSDictionary *info = infoForFile(ent); if (!info) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to retrieve info from file %@", @(ent->fts_path)] }]; } @@ -359,7 +371,9 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF mode_t permissions = [info[INFO_PERMISSIONS_KEY] unsignedShortValue]; if (!IS_VALID_PERMISSIONS(permissions)) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Invalid file permissions after-tree on file %@ (only permissions with modes 0755 and 0644 are supported)", @(ent->fts_path)] }]; } @@ -367,7 +381,9 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF } if (aclExists(ent)) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing ACLs are not supported. Detected ACL in after-tree on file %@", @(ent->fts_path)] }]; } @@ -375,7 +391,9 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF } if (codeSignatureExtendedAttributeExists(ent)) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Diffing code signed extended attributes are not supported. Detected extended attribute in after-tree on file %@", @(ent->fts_path)] }]; } @@ -406,7 +424,9 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF NSString *afterHash = hashOfTreeWithVersion(destination, majorVersion); if (!afterHash) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to generate hash for tree %@", destination] }]; } @@ -516,7 +536,9 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF for (CreateBinaryDeltaOperation *operation in deltaOperations) { NSString *resultPath = [operation resultPath]; if (!resultPath) { - if (verbose) fprintf(stderr, "\n"); + if (verbose) { + fprintf(stderr, "\n"); + } if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create patch from source %@ and destination %@", operation.relativePath, resultPath] }]; } From 0b4488339df5019a0a5b37cb51f0c5ed4c417252 Mon Sep 17 00:00:00 2001 From: Karl Moskowski Date: Fri, 4 Sep 2015 10:29:11 -0400 Subject: [PATCH 21/23] Check for empty strings (as well as nil) in SUHost's -name method --- Sparkle/SUHost.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index 5bb73ac9..07d709e1 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -103,13 +103,13 @@ // Allow host bundle to provide a custom name name = [self objectForInfoDictionaryKey:@"SUBundleName"]; - if (name) return name; + if (name && ![name isEqualToString:@""]) return name; name = [self.bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"]; - if (name) return name; + if (name && ![name isEqualToString:@""]) return name; name = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey]; - if (name) return name; + if (name && ![name isEqualToString:@""]) return name; return [[[NSFileManager defaultManager] displayNameAtPath:[self.bundle bundlePath]] stringByDeletingPathExtension]; } From 3c436ce8440b86d440c7ea8676b98dda0bb598e5 Mon Sep 17 00:00:00 2001 From: Karl Moskowski Date: Fri, 4 Sep 2015 10:35:08 -0400 Subject: [PATCH 22/23] Check for string length instead of emptiness --- Sparkle/SUHost.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index 07d709e1..6f9e7da1 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -103,13 +103,13 @@ // Allow host bundle to provide a custom name name = [self objectForInfoDictionaryKey:@"SUBundleName"]; - if (name && ![name isEqualToString:@""]) return name; + if (name && name.length > 0) return name; name = [self.bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"]; - if (name && ![name isEqualToString:@""]) return name; + if (name && name.length > 0) return name; name = [self objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey]; - if (name && ![name isEqualToString:@""]) return name; + if (name && name.length > 0) return name; return [[[NSFileManager defaultManager] displayNameAtPath:[self.bundle bundlePath]] stringByDeletingPathExtension]; } From 637eaae9c722774e84686b43c3f232e65340c593 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Sat, 5 Sep 2015 14:56:34 -0700 Subject: [PATCH 23/23] Don't run tests for SDKs < 10.10. --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0908eb99..4f1b4a9f 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,12 @@ test: xcodebuild -scheme Distribution -configuration Debug test ci: - for i in {7..11} ; do \ + for i in {7..9} ; do \ + if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \ + ( rm -rf build && xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Coverage -derivedDataPath build ) || exit 1 ; \ + fi ; \ + done + for i in {10..11} ; do \ if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \ ( rm -rf build && xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Coverage -derivedDataPath build test ) || exit 1 ; \ fi ; \