Pass the SUHost into the driver's constructor

This commit is contained in:
Zorg committed 2016-02-28 02:00:57 -05:00
1 parent f630188255
commit 4a3f0ad984
8 files changed
+20 -21

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@
@property (strong, readonly) NSURLDownload *download;
@property (copy, readonly) NSString *downloadPath;
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
- (void)checkForUpdatesAtURL:(NSURL *)URL;
- (BOOL)isItemNewer:(SUAppcastItem *)ui;
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
+4 -4
View File
@@ -49,12 +49,12 @@
@synthesize postponedOnce;
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
- (void)checkForUpdatesAtURL:(NSURL *)URL
{
[super checkForUpdatesAtURL:URL host:aHost];
if ([aHost isRunningOnReadOnlyVolume])
[super checkForUpdatesAtURL:URL];
if ([self.host isRunningOnReadOnlyVolume])
{
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%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.", nil), [aHost name]] }]];
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%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.", nil), [self.host name]] }]];
return;
}
+1 -1
View File
@@ -17,7 +17,7 @@
@interface SUUIBasedUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate>
- (instancetype)initWithUpdater:(SUUpdater *)updater;
- (instancetype)initWithUpdater:(SUUpdater *)updater host:(SUHost *)host;
@end
+2 -2
View File
@@ -15,9 +15,9 @@
@implementation SUUIBasedUpdateDriver
- (instancetype)initWithUpdater:(SUUpdater *)anUpdater
- (instancetype)initWithUpdater:(SUUpdater *)anUpdater host:(SUHost *)aHost
{
if ((self = [super initWithUpdater:anUpdater])) {
if ((self = [super initWithUpdater:anUpdater host:aHost])) {
self.automaticallyInstallUpdates = NO;
}
return self;
+2 -2
View File
@@ -19,8 +19,8 @@ extern NSString *const SUUpdateDriverFinishedNotification;
@property (readonly, weak) SUUpdater *updater;
@property (strong) SUHost *host;
- (instancetype)initWithUpdater:(SUUpdater *)updater;
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host;
- (instancetype)initWithUpdater:(SUUpdater *)updater host:(SUHost *)host;
- (void)checkForUpdatesAtURL:(NSURL *)URL;
- (void)abortUpdate;
@property (getter=isInterruptible, readonly) BOOL interruptible;
+3 -3
View File
@@ -29,20 +29,20 @@ NSString *const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished";
@synthesize appcastURL;
@synthesize automaticallyInstallUpdates;
- (instancetype)initWithUpdater:(SUUpdater *)anUpdater
- (instancetype)initWithUpdater:(SUUpdater *)anUpdater host:(SUHost *)aHost
{
if ((self = [super init])) {
self.updater = anUpdater;
self.host = aHost;
}
return self;
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)h
- (void)checkForUpdatesAtURL:(NSURL *)URL
{
self.appcastURL = URL;
self.host = h;
}
- (void)abortUpdate
+5 -5
View File
@@ -275,7 +275,7 @@ static void SUCheckForUpdatesInBgReachabilityCheck(SUUpdater *updater, SUUpdateD
// Background update checks should only happen if we have a network connection.
// Wouldn't want to annoy users on dial-up by establishing a connection every
// hour or so:
SUUpdateDriver *theUpdateDriver = [[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class])alloc] initWithUpdater:self];
SUUpdateDriver *theUpdateDriver = [[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class])alloc] initWithUpdater:self host:self.host];
// We don't want the rechability check to act on the driver if the updater is going near death
__weak SUUpdater *updater = self;
@@ -296,12 +296,12 @@ static void SUCheckForUpdatesInBgReachabilityCheck(SUUpdater *updater, SUUpdateD
[self.driver abortUpdate];
}
[self checkForUpdatesWithDriver:[[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self]];
[self checkForUpdatesWithDriver:[[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self host:self.host]];
}
- (void)checkForUpdateInformation
{
[self checkForUpdatesWithDriver:[[SUProbingUpdateDriver alloc] initWithUpdater:self]];
[self checkForUpdatesWithDriver:[[SUProbingUpdateDriver alloc] initWithUpdater:self host:self.host]];
}
- (void)installUpdatesIfAvailable
@@ -310,7 +310,7 @@ static void SUCheckForUpdatesInBgReachabilityCheck(SUUpdater *updater, SUUpdateD
[self.driver abortUpdate];
}
SUUserInitiatedUpdateDriver *theUpdateDriver = [[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self];
SUUserInitiatedUpdateDriver *theUpdateDriver = [[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self host:self.host];
theUpdateDriver.automaticallyInstallUpdates = YES;
[self checkForUpdatesWithDriver:theUpdateDriver];
}
@@ -342,7 +342,7 @@ static void SUCheckForUpdatesInBgReachabilityCheck(SUUpdater *updater, SUUpdateD
NSURL *theFeedURL = [self parameterizedFeedURL];
if (theFeedURL) // Use a NIL URL to cancel quietly.
[self.driver checkForUpdatesAtURL:theFeedURL host:self.host];
[self.driver checkForUpdatesAtURL:theFeedURL];
else
[self.driver abortUpdate];
}
+2 -3
View File
@@ -33,8 +33,7 @@
}
}
#warning assign user driver's host in a superclass of this method, possibly the UI driver.. IDK
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
- (void)checkForUpdatesAtURL:(NSURL *)URL
{
[self.updater.userUpdaterDriver showUserInitiatedUpdateCheckWithCompletion:^(SUUserInitiatedCheckStatus completionStatus) {
switch (completionStatus) {
@@ -48,7 +47,7 @@
}
}];
[super checkForUpdatesAtURL:URL host:aHost];
[super checkForUpdatesAtURL:URL];
}
- (void)appcastDidFinishLoading:(SUAppcast *)ac