diff --git a/Autoupdate/AppInstaller.m b/Autoupdate/AppInstaller.m index 9a958d52..8c3814a0 100644 --- a/Autoupdate/AppInstaller.m +++ b/Autoupdate/AppInstaller.m @@ -65,7 +65,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; @property (nonatomic, assign) BOOL shouldRelaunch; @property (nonatomic, assign) BOOL shouldShowUI; -@property (nonatomic) id installer; +@property (nonatomic) id installer; @property (nonatomic) BOOL willCompleteInstallation; @property (nonatomic) BOOL receivedInstallationData; @property (nonatomic) BOOL finishedValidation; @@ -435,7 +435,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; dispatch_async(self.installerQueue, ^{ NSError *installerError = nil; - id installer = [SUInstaller installerForHost:self.host expectedInstallationType:self.installationType updateDirectory:self.updateDirectoryPath error:&installerError]; + id installer = [SUInstaller installerForHost:self.host expectedInstallationType:self.installationType updateDirectory:self.updateDirectoryPath error:&installerError]; if (installer == nil) { SULog(@"Error: Failed to create installer instance with error: %@", installerError); @@ -448,7 +448,6 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; NSError *firstStageError = nil; if (![installer performInitialInstallation:&firstStageError]) { SULog(@"Error: Failed to start installer with error: %@", firstStageError); - [self.installer cleanup]; self.installer = nil; dispatch_async(dispatch_get_main_queue(), ^{ @@ -501,7 +500,6 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; }); } else { SULog(@"Error: Failed to resume installer on stage 2 because installation cannot be installed silently"); - [self.installer cleanup]; self.installer = nil; dispatch_async(dispatch_get_main_queue(), ^{ @@ -556,7 +554,6 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; if (![self.installer performFinalInstallation:&thirdStageError]) { SULog(@"Failed to finalize installation with error: %@", thirdStageError); - [self.installer cleanup]; self.installer = nil; dispatch_async(dispatch_get_main_queue(), ^{ @@ -590,13 +587,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; [self.agentConnection.agent relaunchPath:pathToRelaunch]; } - dispatch_async(self.installerQueue, ^{ - [self.installer cleanup]; - - dispatch_async(dispatch_get_main_queue(), ^{ - [self cleanupAndExitWithStatus:EXIT_SUCCESS]; - }); - }); + [self cleanupAndExitWithStatus:EXIT_SUCCESS]; }); }); }]; diff --git a/Autoupdate/SUGuidedPackageInstaller.h b/Autoupdate/SUGuidedPackageInstaller.h index be1da7ef..29e9389f 100644 --- a/Autoupdate/SUGuidedPackageInstaller.h +++ b/Autoupdate/SUGuidedPackageInstaller.h @@ -17,9 +17,9 @@ A guided installation can be started by applications other than the application */ #import -#import "SPUInstallerProtocol.h" +#import "SUInstallerProtocol.h" -@interface SUGuidedPackageInstaller : NSObject +@interface SUGuidedPackageInstaller : NSObject - (instancetype)initWithPackagePath:(NSString *)packagePath installationPath:(NSString *)installationPath; diff --git a/Autoupdate/SUGuidedPackageInstaller.m b/Autoupdate/SUGuidedPackageInstaller.m index 4e32c6bf..4c229cca 100644 --- a/Autoupdate/SUGuidedPackageInstaller.m +++ b/Autoupdate/SUGuidedPackageInstaller.m @@ -76,8 +76,4 @@ return YES; } -- (void)cleanup -{ -} - @end diff --git a/Autoupdate/SUInstaller.h b/Autoupdate/SUInstaller.h index 7fddd556..2e84049d 100644 --- a/Autoupdate/SUInstaller.h +++ b/Autoupdate/SUInstaller.h @@ -7,7 +7,7 @@ // #import -#import "SPUInstallerProtocol.h" +#import "SUInstallerProtocol.h" NS_ASSUME_NONNULL_BEGIN @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN @interface SUInstaller : NSObject -+ (nullable id)installerForHost:(SUHost *)host expectedInstallationType:(NSString *)expectedInstallationType updateDirectory:(NSString *)updateDirectory error:(NSError **)error; ++ (nullable id)installerForHost:(SUHost *)host expectedInstallationType:(NSString *)expectedInstallationType updateDirectory:(NSString *)updateDirectory error:(NSError **)error; + (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(nullable BOOL *)isGuidedPtr; diff --git a/Autoupdate/SUInstaller.m b/Autoupdate/SUInstaller.m index 92941175..cc4abb11 100644 --- a/Autoupdate/SUInstaller.m +++ b/Autoupdate/SUInstaller.m @@ -112,7 +112,7 @@ return newAppDownloadPath; } -+ (nullable id)installerForHost:(SUHost *)host expectedInstallationType:(NSString *)expectedInstallationType updateDirectory:(NSString *)updateDirectory error:(NSError * __autoreleasing *)error ++ (nullable id)installerForHost:(SUHost *)host expectedInstallationType:(NSString *)expectedInstallationType updateDirectory:(NSString *)updateDirectory error:(NSError * __autoreleasing *)error { BOOL isPackage = NO; BOOL isGuided = NO; @@ -128,7 +128,7 @@ // Make sure we find the type of installer that we were expecting to find // We shouldn't implicitly trust the installation type fed into here from the appcast because the installation type helps us determine // ahead of time whether or not this installer tool should be ran as root or not - id installer = nil; + id installer = nil; if (isPackage && isGuided) { if (![expectedInstallationType isEqualToString:SPUInstallationTypeGuidedPackage]) { if (error != NULL) { diff --git a/Autoupdate/SPUInstallerProtocol.h b/Autoupdate/SUInstallerProtocol.h similarity index 83% rename from Autoupdate/SPUInstallerProtocol.h rename to Autoupdate/SUInstallerProtocol.h index cb97be4a..3d788ff4 100644 --- a/Autoupdate/SPUInstallerProtocol.h +++ b/Autoupdate/SUInstallerProtocol.h @@ -1,5 +1,5 @@ // -// SPUInstallerProtocol.h +// SUInstallerProtocol.h // Sparkle // // Created by Mayur Pawashe on 3/12/16. @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN -@protocol SPUInstallerProtocol +@protocol SUInstallerProtocol // Any installation work can be done prior to user application being terminated and relaunched // No UI should occur during this stage (i.e, do not show package installer apps, etc..) @@ -27,10 +27,6 @@ NS_ASSUME_NONNULL_BEGIN // Should be thread safe - (BOOL)canInstallSilently; -// Cleans up work done from the initial or final installation (depending on how far installation gets) -// Should be able to be called from non-main thread -- (void)cleanup; - // The destination and installation path of the bundle being updated - (NSString *)installationPath; diff --git a/Autoupdate/SUPackageInstaller.h b/Autoupdate/SUPackageInstaller.h index d068dc17..b4375618 100644 --- a/Autoupdate/SUPackageInstaller.h +++ b/Autoupdate/SUPackageInstaller.h @@ -7,12 +7,12 @@ // #import -#import "SPUInstallerProtocol.h" +#import "SUInstallerProtocol.h" // This is the deprecated package installation type, aka the "interactive" package installer // For a more supported package installation, see SUGuidedPackageInstaller -@interface SUPackageInstaller : NSObject +@interface SUPackageInstaller : NSObject - (instancetype)initWithPackagePath:(NSString *)packagePath installationPath:(NSString *)installationPath; diff --git a/Autoupdate/SUPackageInstaller.m b/Autoupdate/SUPackageInstaller.m index 34b3ecb8..15a463d8 100644 --- a/Autoupdate/SUPackageInstaller.m +++ b/Autoupdate/SUPackageInstaller.m @@ -79,8 +79,4 @@ static NSString *SUOpenUtilityPath = @"/usr/bin/open"; return NO; } -- (void)cleanup -{ -} - @end diff --git a/Autoupdate/SUPlainInstaller.h b/Autoupdate/SUPlainInstaller.h index ce946e7f..8820d81c 100644 --- a/Autoupdate/SUPlainInstaller.h +++ b/Autoupdate/SUPlainInstaller.h @@ -7,12 +7,12 @@ // #import -#import "SPUInstallerProtocol.h" +#import "SUInstallerProtocol.h" @class SUHost; @protocol SUVersionComparison; -@interface SUPlainInstaller : NSObject +@interface SUPlainInstaller : NSObject /*! @param host The current (old) bundle host diff --git a/Autoupdate/SUPlainInstaller.m b/Autoupdate/SUPlainInstaller.m index 5c0acd7e..ef244b9d 100644 --- a/Autoupdate/SUPlainInstaller.m +++ b/Autoupdate/SUPlainInstaller.m @@ -25,10 +25,6 @@ @property (nonatomic, copy, readonly) NSString *bundlePath; @property (nonatomic, copy, readonly) NSString *installationPath; -// Properties that carry over from starting installation to resuming to cleaning up -@property (nonatomic) NSURL *tempOldDirectoryURL; -@property (nonatomic) NSURL *tempNewDirectoryURL; - @end @implementation SUPlainInstaller @@ -36,8 +32,6 @@ @synthesize host = _host; @synthesize bundlePath = _bundlePath; @synthesize installationPath = _installationPath; -@synthesize tempOldDirectoryURL = _tempOldDirectoryURL; -@synthesize tempNewDirectoryURL = _tempNewDirectoryURL; - (instancetype)initWithHost:(SUHost *)host bundlePath:(NSString *)bundlePath installationPath:(NSString *)installationPath { @@ -179,9 +173,9 @@ return NO; } - // To carry over when we clean up the installation - self.tempNewDirectoryURL = tempNewDirectoryURL; - self.tempOldDirectoryURL = tempOldDirectoryURL; + // Cleanup + [fileManager removeItemAtURL:tempOldDirectoryURL error:NULL]; + [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; return YES; } @@ -221,26 +215,4 @@ return YES; } -- (void)cleanup -{ - SUFileManager *fileManager = [[SUFileManager alloc] init]; - NSURL *tempOldDirectoryURL = self.tempOldDirectoryURL; - NSURL *tempNewDirectoryURL = self.tempNewDirectoryURL; - - // Note: I'm intentionally not checking if an item at the file URLs exist since these methods already do that for us - - if (tempOldDirectoryURL != nil) { - // This will remove the old app contained inside the directory as well - [fileManager removeItemAtURL:tempOldDirectoryURL error:NULL]; - - self.tempOldDirectoryURL = nil; - } - - if (tempNewDirectoryURL != nil) { - [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; - - self.tempNewDirectoryURL = nil; - } -} - @end diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 98d92705..ad246370 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -999,7 +999,7 @@ 7267E5B01D3D8AD500D1BF90 /* SPUMessageTypes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SPUMessageTypes.m; path = Autoupdate/SPUMessageTypes.m; sourceTree = SOURCE_ROOT; }; 7267E5B41D3D8AEE00D1BF90 /* SPUInstallationInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SPUInstallationInfo.h; path = Autoupdate/SPUInstallationInfo.h; sourceTree = SOURCE_ROOT; }; 7267E5B51D3D8AEE00D1BF90 /* SPUInstallationInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SPUInstallationInfo.m; path = Autoupdate/SPUInstallationInfo.m; sourceTree = SOURCE_ROOT; }; - 7267E5B91D3D8B0B00D1BF90 /* SPUInstallerProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SPUInstallerProtocol.h; path = Autoupdate/SPUInstallerProtocol.h; sourceTree = SOURCE_ROOT; }; + 7267E5B91D3D8B0B00D1BF90 /* SUInstallerProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SUInstallerProtocol.h; path = Autoupdate/SUInstallerProtocol.h; sourceTree = SOURCE_ROOT; }; 7267E5BA1D3D8B2700D1BF90 /* SUGuidedPackageInstaller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUGuidedPackageInstaller.h; path = Autoupdate/SUGuidedPackageInstaller.h; sourceTree = SOURCE_ROOT; }; 7267E5BB1D3D8B2700D1BF90 /* SUGuidedPackageInstaller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SUGuidedPackageInstaller.m; path = Autoupdate/SUGuidedPackageInstaller.m; sourceTree = SOURCE_ROOT; }; 7267E5BC1D3D8B2700D1BF90 /* SUInstaller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUInstaller.h; path = Autoupdate/SUInstaller.h; sourceTree = SOURCE_ROOT; }; @@ -1566,7 +1566,7 @@ 618FA6DB0DB485440026945C /* Installation */ = { isa = PBXGroup; children = ( - 7267E5B91D3D8B0B00D1BF90 /* SPUInstallerProtocol.h */, + 7267E5B91D3D8B0B00D1BF90 /* SUInstallerProtocol.h */, 7267E5BC1D3D8B2700D1BF90 /* SUInstaller.h */, 7267E5BD1D3D8B2700D1BF90 /* SUInstaller.m */, 7267E5C01D3D8B2700D1BF90 /* SUPlainInstaller.h */, diff --git a/Tests/SUInstallerTest.m b/Tests/SUInstallerTest.m index 15c9e085..80d07a98 100644 --- a/Tests/SUInstallerTest.m +++ b/Tests/SUInstallerTest.m @@ -10,7 +10,7 @@ #import #import "SUHost.h" #import "SUInstaller.h" -#import "SPUInstallerProtocol.h" +#import "SUInstallerProtocol.h" #import "SPUInstallationType.h" #import @@ -54,7 +54,7 @@ SUHost *host = [[SUHost alloc] initWithBundle:bundle]; NSError *installerError = nil; - id installer = [SUInstaller installerForHost:host expectedInstallationType:SPUInstallationTypeGuidedPackage updateDirectory:[path stringByDeletingLastPathComponent] error:&installerError]; + id installer = [SUInstaller installerForHost:host expectedInstallationType:SPUInstallationTypeGuidedPackage updateDirectory:[path stringByDeletingLastPathComponent] error:&installerError]; if (installer == nil) { XCTFail(@"Installer is nil with error: %@", installerError); @@ -73,8 +73,6 @@ return; } - [installer cleanup]; - XCTAssertTrue([fm fileExistsAtPath:expectedDestination isDirectory:nil]); [fm removeItemAtPath:expectedDestination error:nil];