Merge pull request #633 from zorgiepoo/no-auto-updates

Disallow automatic updates when user can't write to the bundle
This commit is contained in:
Kornel committed 2015-09-27 02:20:11 +01:00
commit 93a87a4dfd
4 files changed
+26 -7

No files matched your search

+1
View File
@@ -28,6 +28,7 @@ typedef struct {
- (instancetype)initWithBundle:(NSBundle *)aBundle;
@property (readonly, copy) NSString *bundlePath;
@property (readonly) BOOL allowsAutomaticUpdates;
@property (readonly, copy) NSString *appCachePath;
@property (readonly, copy) NSString *installationPath;
@property (readonly, copy) NSString *name;
+12
View File
@@ -62,6 +62,18 @@
return [self.bundle bundlePath];
}
- (BOOL)allowsAutomaticUpdates
{
// Does the developer want us to disable automatic updates?
NSNumber *developerAllowsAutomaticUpdates = [self objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey];
if (developerAllowsAutomaticUpdates != nil && !developerAllowsAutomaticUpdates.boolValue) {
return NO;
}
// Can we automatically update in the background without bugging the user (e.g, with a administrator password prompt)?
return [[NSFileManager defaultManager] isWritableFileAtPath:self.bundlePath];
}
- (NSString *)appCachePath
{
NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+11 -5
View File
@@ -171,11 +171,7 @@
- (BOOL)allowsAutomaticUpdates
{
BOOL allowAutoUpdates = YES; // Defaults to YES.
if ([self.host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey])
allowAutoUpdates = [self.host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey];
return allowAutoUpdates;
return self.host.allowsAutomaticUpdates;
}
- (void)windowDidLoad
@@ -202,6 +198,16 @@
[self.releaseNotesContainerView removeFromSuperview];
}
// When we show release notes, it looks ugly if the install buttons are not closer to the release notes view
// However when we don't show release notes, it looks ugly if the install buttons are too close to the description field. Shrugs.
if (showReleaseNotes && ![self allowsAutomaticUpdates]) {
NSLayoutConstraint *skipButtonToReleaseNotesContainerConstraint = [NSLayoutConstraint constraintWithItem:self.skipButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.releaseNotesContainerView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:12.0];
[self.window.contentView addConstraint:skipButtonToReleaseNotesContainerConstraint];
[self.automaticallyInstallUpdatesButton removeFromSuperview];
}
[self.window center];
}
+2 -2
View File
@@ -435,8 +435,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (BOOL)automaticallyDownloadsUpdates
{
// If the SUAllowsAutomaticUpdatesKey exists and is set to NO, return NO.
if ([self.host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] && [self.host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] == NO) {
// If the host doesn't allow automatic updates, don't ever let them happen
if (!self.host.allowsAutomaticUpdates) {
return NO;
}