mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Allow automatically downloading updates, but alerting the user immediately
Following cases where after an update has been automatically downloaded, Sparkle may alert the user right away: 1) Critical updates 2) Insufficient write access to install without being root 3) Package type installations In addition to alerting the user right away, if they dismiss the update, the schedule timer will be on regular intervals. We also no longer need to care about writability in the updater, only just in the installer.
This commit is contained in:
1 parent
5a0ee5d56a
commit
cd108ef47c
22 files changed
+167
-109
No files matched your search
@@ -35,9 +35,4 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (void)testWritabilityAtPath:(NSString *)path completion:(void (^)(BOOL isWritable))completionHandler
|
||||
{
|
||||
completionHandler([[NSFileManager defaultManager] isWritableFileAtPath:path]);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -11,7 +11,5 @@
|
||||
@protocol SUInstallerLauncherProtocol
|
||||
|
||||
- (void)launchInstallerAtPath:(NSString *)installerPath withArguments:(NSArray *)arguments completion:(void (^)(BOOL success))completionHandler;
|
||||
|
||||
- (void)testWritabilityAtPath:(NSString *)path completion:(void (^)(BOOL isWritable))completionHandler;
|
||||
|
||||
@end
|
||||
@@ -181,8 +181,6 @@
|
||||
726E07BE1CAF0C5C001A286B /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; };
|
||||
726E07BF1CAF0C6C001A286B /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; };
|
||||
726E07C01CAF15B7001A286B /* SULog.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C14F05136EF6DB00649790 /* SULog.m */; };
|
||||
726E07E91CAF30C0001A286B /* SUUpdaterPermission.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E07E71CAF30C0001A286B /* SUUpdaterPermission.h */; };
|
||||
726E07EA1CAF30C0001A286B /* SUUpdaterPermission.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E07E81CAF30C0001A286B /* SUUpdaterPermission.m */; };
|
||||
726E07F41CAF37BD001A286B /* SUUpdateDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E07F31CAF37BD001A286B /* SUUpdateDownloader.m */; };
|
||||
726E07F61CAF37BD001A286B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E07F51CAF37BD001A286B /* main.m */; };
|
||||
726E07FA1CAF37BD001A286B /* UpdateDownloader.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 726E07EF1CAF37BD001A286B /* UpdateDownloader.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
@@ -265,6 +263,10 @@
|
||||
72B767E61C9CFD7200A07552 /* SUAutomaticUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B767E41C9CFD7200A07552 /* SUAutomaticUpdateDriver.h */; };
|
||||
72B767E71C9CFD7200A07552 /* SUAutomaticUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B767E51C9CFD7200A07552 /* SUAutomaticUpdateDriver.m */; };
|
||||
72D4DAA11AD7632900B211E2 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; };
|
||||
72D9547B1CBA1FFF006F28BD /* SUInstallationInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 72D954791CBA1FFE006F28BD /* SUInstallationInfo.h */; };
|
||||
72D9547C1CBA1FFF006F28BD /* SUInstallationInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 72D9547A1CBA1FFE006F28BD /* SUInstallationInfo.m */; };
|
||||
72D9547D1CBA1FFF006F28BD /* SUInstallationInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 72D9547A1CBA1FFE006F28BD /* SUInstallationInfo.m */; };
|
||||
72D9547E1CBA221E006F28BD /* SUAppcastItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B5FC5409C5182000B25A18 /* SUAppcastItem.m */; };
|
||||
72E41A391CB209CA003D47E0 /* SURemoteMessagePortProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 72E41A381CB209CA003D47E0 /* SURemoteMessagePortProtocol.h */; };
|
||||
72E41A451CB20BA7003D47E0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E41A441CB20BA7003D47E0 /* main.m */; };
|
||||
72E41A491CB20BA7003D47E0 /* RemoteMessagePort.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 72E41A3E1CB20BA7003D47E0 /* RemoteMessagePort.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
@@ -764,8 +766,6 @@
|
||||
726E07B31CAF08D6001A286B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
726E07B51CAF08D6001A286B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
726E07C11CAF1E79001A286B /* ConfigInstallerLauncher.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigInstallerLauncher.xcconfig; sourceTree = "<group>"; };
|
||||
726E07E71CAF30C0001A286B /* SUUpdaterPermission.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdaterPermission.h; sourceTree = "<group>"; };
|
||||
726E07E81CAF30C0001A286B /* SUUpdaterPermission.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdaterPermission.m; sourceTree = "<group>"; };
|
||||
726E07EF1CAF37BD001A286B /* UpdateDownloader.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = UpdateDownloader.xpc; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
726E07F11CAF37BD001A286B /* SUUpdateDownloaderProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SUUpdateDownloaderProtocol.h; sourceTree = "<group>"; };
|
||||
726E07F21CAF37BD001A286B /* SUUpdateDownloader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SUUpdateDownloader.h; sourceTree = "<group>"; };
|
||||
@@ -846,6 +846,8 @@
|
||||
72B767E11C9CE90A00A07552 /* SUCoreBasedUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUCoreBasedUpdateDriver.m; sourceTree = "<group>"; };
|
||||
72B767E41C9CFD7200A07552 /* SUAutomaticUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUAutomaticUpdateDriver.h; sourceTree = "<group>"; };
|
||||
72B767E51C9CFD7200A07552 /* SUAutomaticUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUAutomaticUpdateDriver.m; sourceTree = "<group>"; };
|
||||
72D954791CBA1FFE006F28BD /* SUInstallationInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUInstallationInfo.h; sourceTree = "<group>"; };
|
||||
72D9547A1CBA1FFE006F28BD /* SUInstallationInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUInstallationInfo.m; sourceTree = "<group>"; };
|
||||
72E41A381CB209CA003D47E0 /* SURemoteMessagePortProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SURemoteMessagePortProtocol.h; path = Sparkle/SURemoteMessagePortProtocol.h; sourceTree = SOURCE_ROOT; };
|
||||
72E41A3E1CB20BA7003D47E0 /* RemoteMessagePort.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = RemoteMessagePort.xpc; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
72E41A441CB20BA7003D47E0 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
@@ -1386,8 +1388,6 @@
|
||||
61CFB2C20E38496B007A1735 /* Drivers */,
|
||||
61B5F8E309C4CE3C00B25A18 /* SUUpdater.h */,
|
||||
61B5F8E409C4CE3C00B25A18 /* SUUpdater.m */,
|
||||
726E07E71CAF30C0001A286B /* SUUpdaterPermission.h */,
|
||||
726E07E81CAF30C0001A286B /* SUUpdaterPermission.m */,
|
||||
726E078B1CA891E9001A286B /* SUUpdaterSettings.h */,
|
||||
726E078C1CA891E9001A286B /* SUUpdaterSettings.m */,
|
||||
72A6F9891C94E2D6005F404C /* SUUpdaterDelegate.h */,
|
||||
@@ -1503,6 +1503,8 @@
|
||||
729746561C936D5E00FC134E /* SUMessageTypes.m */,
|
||||
726E075A1CA3A6D6001A286B /* SUSecureCoding.h */,
|
||||
726E075B1CA3A6D6001A286B /* SUSecureCoding.m */,
|
||||
72D954791CBA1FFE006F28BD /* SUInstallationInfo.h */,
|
||||
72D9547A1CBA1FFE006F28BD /* SUInstallationInfo.m */,
|
||||
);
|
||||
name = IPC;
|
||||
path = Autoupdate;
|
||||
@@ -1619,7 +1621,6 @@
|
||||
726E07601CA4E9A5001A286B /* SUInstallationInputData.h in Headers */,
|
||||
725602D51C83551C00DAA70E /* SUApplicationInfo.h in Headers */,
|
||||
767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */,
|
||||
726E07E91CAF30C0001A286B /* SUUpdaterPermission.h in Headers */,
|
||||
618FA5010DAE88B40026945C /* SUInstaller.h in Headers */,
|
||||
55C14F06136EF6DB00649790 /* SULog.h in Headers */,
|
||||
72E41A531CB21125003D47E0 /* SUXPCRemoteMessagePort.h in Headers */,
|
||||
@@ -1640,6 +1641,7 @@
|
||||
6196CFF909C72148000DC222 /* SUStatusController.h in Headers */,
|
||||
72B767DE1C9CDB9700A07552 /* SUUserInitiatedUpdateDriver.h in Headers */,
|
||||
61A2279C0D1CEE7600430CCD /* SUSystemProfiler.h in Headers */,
|
||||
72D9547B1CBA1FFF006F28BD /* SUInstallationInfo.h in Headers */,
|
||||
72B767D21C9C7B9300A07552 /* SUProbingUpdateDriver.h in Headers */,
|
||||
7229E1BD1C98EFF200CB50D0 /* SUDownloadDriver.h in Headers */,
|
||||
72B767CE1C9B924900A07552 /* SUInstallerDriver.h in Headers */,
|
||||
@@ -2258,11 +2260,13 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
72D9547E1CBA221E006F28BD /* SUAppcastItem.m in Sources */,
|
||||
726E07671CA61648001A286B /* SUBinaryDeltaCommon.m in Sources */,
|
||||
726E07661CA61621001A286B /* bspatch.c in Sources */,
|
||||
726E07651CA61603001A286B /* SUBinaryDeltaApply.m in Sources */,
|
||||
726E07641CA615ED001A286B /* SUBinaryDeltaUnarchiver.m in Sources */,
|
||||
726E07631CA4F35F001A286B /* SUSecureCoding.m in Sources */,
|
||||
72D9547D1CBA1FFF006F28BD /* SUInstallationInfo.m in Sources */,
|
||||
7297463A1C8FCA4900FC134E /* SUDSAVerifier.m in Sources */,
|
||||
729746391C8FC04F00FC134E /* SUDiskImageUnarchiver.m in Sources */,
|
||||
729746381C8FC04B00FC134E /* SUPipedUnarchiver.m in Sources */,
|
||||
@@ -2432,6 +2436,7 @@
|
||||
files = (
|
||||
72B767E31C9CE90A00A07552 /* SUCoreBasedUpdateDriver.m in Sources */,
|
||||
7297463C1C8FF6AE00FC134E /* SUCodeSigningVerifier.m in Sources */,
|
||||
72D9547C1CBA1FFF006F28BD /* SUInstallationInfo.m in Sources */,
|
||||
72B767E71C9CFD7200A07552 /* SUAutomaticUpdateDriver.m in Sources */,
|
||||
61B5FBB709C4FAFF00B25A18 /* SUAppcast.m in Sources */,
|
||||
726E078E1CA891E9001A286B /* SUUpdaterSettings.m in Sources */,
|
||||
@@ -2449,7 +2454,6 @@
|
||||
726E07611CA4E9A5001A286B /* SUInstallationInputData.m in Sources */,
|
||||
7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */,
|
||||
72E41A541CB21125003D47E0 /* SUXPCRemoteMessagePort.m in Sources */,
|
||||
726E07EA1CAF30C0001A286B /* SUUpdaterPermission.m in Sources */,
|
||||
725CB95B1C7121830064365A /* SUStandardUserDriver.m in Sources */,
|
||||
61EF67560E25B58D00F754E0 /* SUHost.m in Sources */,
|
||||
55C14F07136EF6DB00649790 /* SULog.m in Sources */,
|
||||
|
||||
Vendored
+17
-5
@@ -22,6 +22,8 @@
|
||||
#import "SUInstallationInputData.h"
|
||||
#import "SUUnarchiver.h"
|
||||
#import "SUFileManager.h"
|
||||
#import "SUInstallationInfo.h"
|
||||
#import "SUAppcastItem.h"
|
||||
|
||||
/*!
|
||||
* Terminate the application after a delay from launching the new update to avoid OS activation issues
|
||||
@@ -48,7 +50,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
@property (nonatomic) SUInstallationInputData *installationData;
|
||||
@property (nonatomic, assign) BOOL shouldRelaunch;
|
||||
@property (nonatomic, assign) BOOL shouldShowUI;
|
||||
@property (nonatomic) NSData *updateItemData;
|
||||
@property (nonatomic) NSData *installationInfoData;
|
||||
|
||||
@property (nonatomic) id<SUInstaller> installer;
|
||||
@property (nonatomic) BOOL willCompleteInstallation;
|
||||
@@ -70,7 +72,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
@synthesize installationData = _installationData;
|
||||
@synthesize shouldRelaunch = _shouldRelaunch;
|
||||
@synthesize shouldShowUI = _shouldShowUI;
|
||||
@synthesize updateItemData = _updateItemData;
|
||||
@synthesize installationInfoData = _installationInfoData;
|
||||
@synthesize installer = _installer;
|
||||
@synthesize willCompleteInstallation = _willCompleteInstallation;
|
||||
@synthesize installerQueue = _installerQueue;
|
||||
@@ -342,9 +344,16 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
}
|
||||
});
|
||||
} else if (identifier == SUSentUpdateAppcastItemData) {
|
||||
self.updateItemData = data;
|
||||
if (self.installationInfoData == nil) {
|
||||
SUAppcastItem *updateItem = (SUAppcastItem *)SUUnarchiveRootObjectSecurely(data, [SUAppcastItem class]);
|
||||
if (updateItem != nil) {
|
||||
SUInstallationInfo *installationInfo = [[SUInstallationInfo alloc] initWithAppcastItem:updateItem canSilentlyInstall:[self.installer canInstallSilently]];
|
||||
|
||||
self.installationInfoData = SUArchiveRootObjectSecurely(installationInfo);
|
||||
}
|
||||
}
|
||||
} else if (identifier == SUReceiveUpdateAppcastItemData) {
|
||||
replyData = self.updateItemData;
|
||||
replyData = self.installationInfoData;
|
||||
} else if (identifier == SUResumeInstallationToStage2 && data.length == sizeof(uint8_t) * 2) {
|
||||
uint8_t relaunch = *((const uint8_t *)data.bytes);
|
||||
uint8_t showsUI = *((const uint8_t *)data.bytes + 1);
|
||||
@@ -403,10 +412,13 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t canPerformSilentInstall = (uint8_t)[installer canInstallSilently];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.installer = installer;
|
||||
|
||||
[self.remotePort sendMessageWithIdentifier:SUInstallationFinishedStage1 data:[NSData data] completion:^(BOOL success) {
|
||||
NSData *silentData = [NSData dataWithBytes:&canPerformSilentInstall length:sizeof(canPerformSilentInstall)];
|
||||
[self.remotePort sendMessageWithIdentifier:SUInstallationFinishedStage1 data:silentData completion:^(BOOL success) {
|
||||
if (!success) {
|
||||
SULog(@"Error sending stage 1 finish");
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// SUInstallationInfo.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 4/10/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SUAppcastItem;
|
||||
|
||||
@interface SUInstallationInfo : NSObject <NSSecureCoding>
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem canSilentlyInstall:(BOOL)canSilentyInstall;
|
||||
|
||||
@property (nonatomic, readonly) SUAppcastItem *appcastItem;
|
||||
@property (nonatomic, readonly) BOOL canSilentlyInstall;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// SUInstallationInfo.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 4/10/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUInstallationInfo.h"
|
||||
#import "SUAppcastItem.h"
|
||||
|
||||
static NSString *SUAppcastItemKey = @"SUAppcastItem";
|
||||
static NSString *SUCanSilentlyInstallKey = @"SUCanSilentlyInstall";
|
||||
|
||||
@implementation SUInstallationInfo
|
||||
|
||||
@synthesize appcastItem = _appcastItem;
|
||||
@synthesize canSilentlyInstall = _canSilentlyInstall;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)appcastItem canSilentlyInstall:(BOOL)canSilentlyInstall
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_appcastItem = appcastItem;
|
||||
_canSilentlyInstall = canSilentlyInstall;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)decoder
|
||||
{
|
||||
SUAppcastItem *appcastItem = [decoder decodeObjectOfClass:[SUAppcastItem class] forKey:SUAppcastItemKey];
|
||||
if (appcastItem == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
BOOL canSilentlyInstall = [decoder decodeBoolForKey:SUCanSilentlyInstallKey];
|
||||
return [self initWithAppcastItem:appcastItem canSilentlyInstall:canSilentlyInstall];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[coder encodeObject:self.appcastItem forKey:SUAppcastItemKey];
|
||||
[coder encodeBool:self.canSilentlyInstall forKey:SUCanSilentlyInstallKey];
|
||||
}
|
||||
|
||||
+ (BOOL)supportsSecureCoding
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
+8
-1
@@ -16,7 +16,7 @@
|
||||
- (BOOL)performFirstStage:(NSError **)error;
|
||||
|
||||
// Stage 2 is where any further installation work can be done prior to the user application being terminated
|
||||
// The allowsUI flag indicates whether this stage can show UI or not, possibly affecting whether or not this stage succeeds.
|
||||
// The allowsUI flag indicates whether this and the 3rd stage can show UI or not, possibly affecting whether or not this stage succeeds.
|
||||
// Eg: This may be appropriate for first showing an authorization prompt before the user application is terminated (if the operation succeeds)
|
||||
// Should be able to be called from non-main thread
|
||||
- (BOOL)performSecondStageAllowingUI:(BOOL)allowsUI error:(NSError **)error;
|
||||
@@ -27,8 +27,15 @@
|
||||
- (BOOL)performThirdStage:(NSError **)error;
|
||||
|
||||
// Indicates whether or not this installer will show the user visible installation progress
|
||||
// Should be thread safe
|
||||
- (BOOL)displaysUserProgress;
|
||||
|
||||
// Indicates whether or not this installer can install the update silently in the background, without hindering the user
|
||||
// This should be considered after stage 1 and before stage 2 of the installation.
|
||||
// If this returns NO, then the second stage of the installation should fail if it is not allowed to show UI.
|
||||
// Should be thread safe
|
||||
- (BOOL)canInstallSilently;
|
||||
|
||||
// Cleans up work done from any of the previous stages. This should be invoked after stage 3 succeeds,
|
||||
// or after any one of the stages fails.
|
||||
// Should be able to be called from non-main thread
|
||||
|
||||
Vendored
+6
-2
@@ -22,6 +22,7 @@
|
||||
|
||||
@property (nonatomic, readonly) SUCoreBasedUpdateDriver *coreDriver;
|
||||
@property (nonatomic) BOOL foundCriticalUpdate;
|
||||
@property (nonatomic) BOOL canInstallSilently;
|
||||
|
||||
@end
|
||||
|
||||
@@ -29,6 +30,7 @@
|
||||
|
||||
@synthesize coreDriver = _coreDriver;
|
||||
@synthesize foundCriticalUpdate = _foundCriticalUpdate;
|
||||
@synthesize canInstallSilently = _canInstallSilently;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id <SUUpdaterDelegate>)updaterDelegate
|
||||
{
|
||||
@@ -58,8 +60,10 @@
|
||||
[self.coreDriver downloadUpdateFromAppcastItem:updateItem];
|
||||
}
|
||||
|
||||
- (void)installerDidFinishRelaunchPreparation
|
||||
- (void)installerDidFinishPreparationAndCanInstallSilently:(BOOL)canInstallSilently
|
||||
{
|
||||
self.canInstallSilently = canInstallSilently;
|
||||
|
||||
// We are done and can safely abort now
|
||||
// The installer tool will keep the installation alive
|
||||
[self abortUpdate];
|
||||
@@ -67,7 +71,7 @@
|
||||
|
||||
- (BOOL)basicDriverShouldSignalShowingUpdateImmediately
|
||||
{
|
||||
return self.foundCriticalUpdate;
|
||||
return (!self.canInstallSilently || self.foundCriticalUpdate);
|
||||
}
|
||||
|
||||
- (void)basicDriverIsRequestingAbortUpdateWithError:(NSError *)error
|
||||
|
||||
Vendored
+3
-1
@@ -15,6 +15,7 @@
|
||||
#import "SUHost.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUProbeInstallStatus.h"
|
||||
#import "SUInstallationInfo.h"
|
||||
|
||||
@interface SUBasicUpdateDriver () <SUAppcastDriverDelegate>
|
||||
|
||||
@@ -67,8 +68,9 @@
|
||||
{
|
||||
self.completionBlock = completionBlock;
|
||||
|
||||
[SUProbeInstallStatus probeInstallerUpdateItemForHost:self.host completion:^(SUAppcastItem * _Nullable updateItem) {
|
||||
[SUProbeInstallStatus probeInstallerUpdateItemForHost:self.host completion:^(SUInstallationInfo * _Nullable installationInfo) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SUAppcastItem *updateItem = installationInfo.appcastItem;
|
||||
if (updateItem == nil) {
|
||||
[self.delegate basicDriverIsRequestingAbortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUResumeAppcastError userInfo:@{ NSLocalizedDescriptionKey: SULocalizedString(@"Failed to resume installing update.", nil) }]];
|
||||
} else {
|
||||
|
||||
Vendored
+1
-1
@@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem;
|
||||
|
||||
- (void)installerDidFinishRelaunchPreparation;
|
||||
- (void)installerDidFinishPreparationAndCanInstallSilently:(BOOL)canInstallSilently;
|
||||
|
||||
- (void)coreDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error;
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -192,9 +192,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)installerDidFinishRelaunchPreparation
|
||||
- (void)installerDidFinishPreparationAndCanInstallSilently:(BOOL)canInstallSilently
|
||||
{
|
||||
[self.delegate installerDidFinishRelaunchPreparation];
|
||||
[self.delegate installerDidFinishPreparationAndCanInstallSilently:canInstallSilently];
|
||||
}
|
||||
|
||||
- (void)finishInstallationWithResponse:(SUInstallUpdateStatus)installUpdateStatus
|
||||
|
||||
Vendored
+5
@@ -91,6 +91,11 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)canInstallSilently
|
||||
{
|
||||
return NO; // because of authorization
|
||||
}
|
||||
|
||||
- (void)cleanup
|
||||
{
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)installerDidStartInstalling;
|
||||
- (void)installerDidExtractUpdateWithProgress:(double)progress;
|
||||
- (void)installerDidFinishRelaunchPreparation;
|
||||
- (void)installerDidFinishPreparationAndCanInstallSilently:(BOOL)canInstallSilently;
|
||||
- (void)installerIsRequestingAppTermination;
|
||||
|
||||
- (void)installerIsRequestingAbortInstallWithError:(nullable NSError *)error;
|
||||
|
||||
Vendored
+6
-1
@@ -301,7 +301,12 @@
|
||||
SULog(@"Error: Archived data to send for appcast item is nil");
|
||||
}
|
||||
|
||||
[self.delegate installerDidFinishRelaunchPreparation];
|
||||
BOOL canInstallSilently = NO;
|
||||
if (data.length == sizeof(uint8_t)) {
|
||||
canInstallSilently = (BOOL)*(const uint8_t *)data.bytes;
|
||||
}
|
||||
|
||||
[self.delegate installerDidFinishPreparationAndCanInstallSilently:canInstallSilently];
|
||||
} else if (identifier == SUInstallationFinishedStage2) {
|
||||
// Don't have to store current stage because we're severing our connection to the installer
|
||||
|
||||
|
||||
Vendored
+5
@@ -77,6 +77,11 @@ static NSString *SUOpenUtilityPath = @"/usr/bin/open";
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)canInstallSilently
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)cleanup
|
||||
{
|
||||
}
|
||||
|
||||
Vendored
+7
-2
@@ -228,8 +228,7 @@
|
||||
self.fileManager = [SUFileManager fileManagerAllowingAuthorization:allowsUI];
|
||||
|
||||
// Bring up authorization prompt right away if we need it
|
||||
#warning is this test good enough or should we check parent directory too?
|
||||
if (![[NSFileManager defaultManager] isWritableFileAtPath:self.host.bundle.bundlePath]) {
|
||||
if (![self canInstallSilently]) {
|
||||
return [self.fileManager grantAuthorizationPrivilegesWithError:error];
|
||||
}
|
||||
return YES;
|
||||
@@ -247,6 +246,12 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)canInstallSilently
|
||||
{
|
||||
#warning is this test good enough or should we check parent directory too?
|
||||
return [[NSFileManager defaultManager] isWritableFileAtPath:self.host.bundle.bundlePath];
|
||||
}
|
||||
|
||||
- (void)cleanup
|
||||
{
|
||||
SUFileManager *fileManager = [self.fileManager fileManagerByPreservingAuthorizationRights];;
|
||||
|
||||
Vendored
+3
-3
@@ -10,15 +10,15 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SUHost, SUAppcastItem;
|
||||
@class SUHost, SUInstallationInfo;
|
||||
|
||||
@interface SUProbeInstallStatus : NSObject
|
||||
|
||||
+ (void)probeInstallerInProgressForHost:(SUHost *)host completion:(void (^)(BOOL))completionHandler;
|
||||
|
||||
// completionHandler may not be sent on main queue
|
||||
// additionally, it may be possible that the installer is in progress but we get a nil appcast item back
|
||||
+ (void)probeInstallerUpdateItemForHost:(SUHost *)host completion:(void (^)(SUAppcastItem * _Nullable))completionHandler;
|
||||
// additionally, it may be possible that the installer is in progress but we get a nil installation info back
|
||||
+ (void)probeInstallerUpdateItemForHost:(SUHost *)host completion:(void (^)(SUInstallationInfo * _Nullable))completionHandler;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+5
-5
@@ -12,7 +12,7 @@
|
||||
#import "SURemoteMessagePortProtocol.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUMessageTypes.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUInstallationInfo.h"
|
||||
#import "SUSecureCoding.h"
|
||||
|
||||
@implementation SUProbeInstallStatus
|
||||
@@ -32,7 +32,7 @@
|
||||
}];
|
||||
}
|
||||
|
||||
+ (void)probeInstallerUpdateItemForHost:(SUHost *)host completion:(void (^)(SUAppcastItem * _Nullable))completionHandler
|
||||
+ (void)probeInstallerUpdateItemForHost:(SUHost *)host completion:(void (^)(SUInstallationInfo * _Nullable))completionHandler
|
||||
{
|
||||
NSString *hostBundleIdentifier = host.bundle.bundleIdentifier;
|
||||
assert(hostBundleIdentifier != nil);
|
||||
@@ -50,10 +50,10 @@
|
||||
completionHandler(nil);
|
||||
} else {
|
||||
NSData *nonNullReplyData = replyData;
|
||||
SUAppcastItem *updateItem = (SUAppcastItem *)SUUnarchiveRootObjectSecurely(nonNullReplyData, [SUAppcastItem class]);
|
||||
SUInstallationInfo *installationInfo = (SUInstallationInfo *)SUUnarchiveRootObjectSecurely(nonNullReplyData, [SUInstallationInfo class]);
|
||||
|
||||
if (updateItem != nil) {
|
||||
completionHandler(updateItem);
|
||||
if (installationInfo != nil) {
|
||||
completionHandler(installationInfo);
|
||||
} else {
|
||||
completionHandler(nil);
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -156,7 +156,7 @@
|
||||
[self.userDriver showExtractionReceivedProgress:progress];
|
||||
}
|
||||
|
||||
- (void)installerDidFinishRelaunchPreparation
|
||||
- (void)installerDidFinishPreparationAndCanInstallSilently:(BOOL)__unused canInstallSilently
|
||||
{
|
||||
[self.userDriver showExtractionFinishedAndReadyToInstallAndRelaunch:^(SUInstallUpdateStatus installUpdateStatus) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
Vendored
+9
-20
@@ -23,7 +23,7 @@
|
||||
#import "SUAutomaticUpdateDriver.h"
|
||||
#import "SUProbeInstallStatus.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUUpdaterPermission.h"
|
||||
#import "SUInstallationInfo.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "core" class and should NOT import AppKit
|
||||
@@ -44,7 +44,6 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
@property (strong) id <SUUpdateDriver> driver;
|
||||
@property (strong) SUHost *host;
|
||||
@property (nonatomic, readonly) SUUpdaterSettings *updaterSettings;
|
||||
@property (nonatomic, readonly) BOOL hasWriteAccessToHostPath;
|
||||
|
||||
@end
|
||||
|
||||
@@ -57,7 +56,6 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
@synthesize driver;
|
||||
@synthesize host;
|
||||
@synthesize updaterSettings = _updaterSettings;
|
||||
@synthesize hasWriteAccessToHostPath = _hasWriteAccessToHostPath;
|
||||
@synthesize sparkleBundle;
|
||||
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)bundle userDriver:(id <SUUserDriver>)userDriver delegate:(id <SUUpdaterDelegate>)theDelegate
|
||||
@@ -80,21 +78,12 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
|
||||
delegate = theDelegate;
|
||||
|
||||
__weak SUUpdater *weakSelf = self;
|
||||
[SUUpdaterPermission testUpdateWritabilityAtPath:host.bundlePath completion:^(BOOL isWritable) {
|
||||
SUUpdater *strongSelf = weakSelf;
|
||||
if (strongSelf == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
strongSelf->_hasWriteAccessToHostPath = isWritable;
|
||||
// This runs the permission prompt if needed, but never before the app has finished launching because the runloop may not have ran before that
|
||||
// We will also take precaussions if a developer instantiates an updater themselves where the application may not be completely finished launching yet
|
||||
[strongSelf performSelector:@selector(startUpdateCycle) withObject:nil afterDelay:1];
|
||||
// This runs the permission prompt if needed, but never before the app has finished launching because the runloop may not have ran before that
|
||||
// We will also take precaussions if a developer instantiates an updater themselves where the application may not be completely finished launching yet
|
||||
[self performSelector:@selector(startUpdateCycle) withObject:nil afterDelay:1];
|
||||
#ifdef DEBUG
|
||||
SULog(@"WARNING: This is running a Debug build of Sparkle; don't use this in production!");
|
||||
SULog(@"WARNING: This is running a Debug build of Sparkle; don't use this in production!");
|
||||
#endif
|
||||
}];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -494,7 +483,7 @@ static void SUCheckForUpdatesInBgReachabilityCheck(__weak SUUpdater *updater, id
|
||||
- (BOOL)allowsAutomaticUpdates
|
||||
{
|
||||
NSNumber *developerAllowsAutomaticUpdates = [self.host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey];
|
||||
return self.hasWriteAccessToHostPath && (developerAllowsAutomaticUpdates == nil || developerAllowsAutomaticUpdates.boolValue);
|
||||
return (developerAllowsAutomaticUpdates == nil || developerAllowsAutomaticUpdates.boolValue);
|
||||
}
|
||||
|
||||
- (void)setFeedURL:(NSURL *)feedURL
|
||||
@@ -611,14 +600,14 @@ static void SUCheckForUpdatesInBgReachabilityCheck(__weak SUUpdater *updater, id
|
||||
// as well as if that update is marked critical or not
|
||||
- (void)retrieveNextUpdateCheckInterval:(void (^)(NSTimeInterval))completionHandler
|
||||
{
|
||||
[SUProbeInstallStatus probeInstallerUpdateItemForHost:self.host completion:^(SUAppcastItem * _Nullable updateItem) {
|
||||
[SUProbeInstallStatus probeInstallerUpdateItemForHost:self.host completion:^(SUInstallationInfo * _Nullable installationInfo) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSTimeInterval regularCheckInterval = [self updateCheckInterval];
|
||||
if (updateItem == nil) {
|
||||
if (installationInfo == nil) {
|
||||
// Proceed as normal if there's no resumable updates
|
||||
completionHandler(regularCheckInterval);
|
||||
} else {
|
||||
if ([updateItem isCriticalUpdate]) {
|
||||
if (!installationInfo.canSilentlyInstall || [installationInfo.appcastItem isCriticalUpdate]) {
|
||||
completionHandler(MIN(regularCheckInterval, SUImpatientUpdateCheckInterval));
|
||||
} else {
|
||||
completionHandler(MAX(regularCheckInterval, SUImpatientUpdateCheckInterval));
|
||||
|
||||
Vendored
-20
@@ -1,20 +0,0 @@
|
||||
//
|
||||
// SUUpdaterPermission.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 4/1/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUUpdaterPermission : NSObject
|
||||
|
||||
// Must be called from main queue
|
||||
+ (void)testUpdateWritabilityAtPath:(NSString *)path completion:(void (^)(BOOL))completionHandler;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
-29
@@ -1,29 +0,0 @@
|
||||
//
|
||||
// SUUpdaterPermission.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 4/1/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUUpdaterPermission.h"
|
||||
#import "SUInstallerLauncherProtocol.h"
|
||||
|
||||
@implementation SUUpdaterPermission
|
||||
|
||||
+ (void)testUpdateWritabilityAtPath:(NSString *)path completion:(void (^)(BOOL))completionHandler
|
||||
{
|
||||
NSXPCConnection *launcherConnection = [[NSXPCConnection alloc] initWithServiceName:@"org.sparkle-project.InstallerLauncher"];
|
||||
launcherConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerLauncherProtocol)];
|
||||
[launcherConnection resume];
|
||||
|
||||
[launcherConnection.remoteObjectProxy testWritabilityAtPath:path completion:^(BOOL isWritable) {
|
||||
[launcherConnection invalidate];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
completionHandler(isWritable);
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user