diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 789753cb..32bc7445 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -233,6 +233,10 @@ 7267E5F81D3D91A800D1BF90 /* SUPipedUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5831D3D89B300D1BF90 /* SUPipedUnarchiver.m */; }; 7267E5F91D3D92DA00D1BF90 /* Autoupdate in CopyFiles */ = {isa = PBXBuildFile; fileRef = 72B398D21D3D879300EE297F /* Autoupdate */; }; 7267E5FA1D3DAC3600D1BF90 /* StatusInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5A41D3D8A8A00D1BF90 /* StatusInfo.m */; }; + 7267E5FD1D3DD1B700D1BF90 /* SUDownloadedUpdate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7267E5FB1D3DD1B700D1BF90 /* SUDownloadedUpdate.h */; }; + 7267E5FE1D3DD1B700D1BF90 /* SUDownloadedUpdate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5FC1D3DD1B700D1BF90 /* SUDownloadedUpdate.m */; }; + 7267E5FF1D3DD1B700D1BF90 /* SUDownloadedUpdate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5FC1D3DD1B700D1BF90 /* SUDownloadedUpdate.m */; }; + 7267E6001D3DD1B700D1BF90 /* SUDownloadedUpdate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7267E5FC1D3DD1B700D1BF90 /* SUDownloadedUpdate.m */; }; 726DF88E1C84277600188804 /* SUStatusCompletionResults.h in Headers */ = {isa = PBXBuildFile; fileRef = 726DF88D1C84277500188804 /* SUStatusCompletionResults.h */; settings = {ATTRIBUTES = (Public, ); }; }; 726E075C1CA3A6D6001A286B /* SUSecureCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 726E075A1CA3A6D6001A286B /* SUSecureCoding.h */; }; 726E075D1CA3A6D6001A286B /* SUSecureCoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 726E075B1CA3A6D6001A286B /* SUSecureCoding.m */; }; @@ -881,6 +885,8 @@ 7267E5DD1D3D8F5A00D1BF90 /* SUStatusInfoProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SUStatusInfoProtocol.h; path = Autoupdate/SUStatusInfoProtocol.h; sourceTree = SOURCE_ROOT; }; 7267E5E31D3D90AA00D1BF90 /* SUFileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUFileManager.h; sourceTree = ""; }; 7267E5E41D3D90AA00D1BF90 /* SUFileManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUFileManager.m; sourceTree = ""; }; + 7267E5FB1D3DD1B700D1BF90 /* SUDownloadedUpdate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUDownloadedUpdate.h; sourceTree = ""; }; + 7267E5FC1D3DD1B700D1BF90 /* SUDownloadedUpdate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDownloadedUpdate.m; sourceTree = ""; }; 726B2B5D1C645FC900388755 /* UI Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "UI Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 726DF88D1C84277500188804 /* SUStatusCompletionResults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUStatusCompletionResults.h; sourceTree = ""; }; 726E075A1CA3A6D6001A286B /* SUSecureCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUSecureCoding.h; path = Sparkle/SUSecureCoding.h; sourceTree = SOURCE_ROOT; }; @@ -1520,6 +1526,8 @@ 72B767C91C9B707000A07552 /* SUAppcastDriver.m */, 728337A41C9E6FF40085AA99 /* SUProbeInstallStatus.h */, 728337A51C9E6FF40085AA99 /* SUProbeInstallStatus.m */, + 7267E5FB1D3DD1B700D1BF90 /* SUDownloadedUpdate.h */, + 7267E5FC1D3DD1B700D1BF90 /* SUDownloadedUpdate.m */, ); name = Drivers; sourceTree = ""; @@ -1825,6 +1833,7 @@ 61299A5C09CA6D4500B7442F /* SUConstants.h in Headers */, 55E6F33319EC9F6C00005E76 /* SUErrors.h in Headers */, 14652F8419A978C200959E44 /* SUExport.h in Headers */, + 7267E5FD1D3DD1B700D1BF90 /* SUDownloadedUpdate.h in Headers */, 725602D51C83551C00DAA70E /* SUApplicationInfo.h in Headers */, 55C14F06136EF6DB00649790 /* SULog.h in Headers */, 726F2CE51BC9C33D001971A4 /* SUOperatingSystem.h in Headers */, @@ -2504,6 +2513,7 @@ 7267E5781D3D895B00D1BF90 /* SUBinaryDeltaCommon.m in Sources */, 5D06E8E90FD68CDB005AE3F6 /* bsdiff.c in Sources */, 14652F7E19A9728A00959E44 /* bspatch.c in Sources */, + 7267E6001D3DD1B700D1BF90 /* SUDownloadedUpdate.m in Sources */, 7223E7631AD1AEFF008E3161 /* sais.c in Sources */, 72B09CEC1CEA18900052EF9E /* bscommon.c in Sources */, 7267E5761D3D895B00D1BF90 /* SUBinaryDeltaApply.m in Sources */, @@ -2522,6 +2532,7 @@ 7267E5F81D3D91A800D1BF90 /* SUPipedUnarchiver.m in Sources */, 7267E5F71D3D919600D1BF90 /* SUPlainInstaller.m in Sources */, 7267E5F61D3D919000D1BF90 /* SUDiskImageUnarchiver.m in Sources */, + 7267E5FF1D3DD1B700D1BF90 /* SUDownloadedUpdate.m in Sources */, 7267E5F41D3D918B00D1BF90 /* SUGuidedPackageInstaller.m in Sources */, 7267E5F51D3D918B00D1BF90 /* SUPackageInstaller.m in Sources */, 7267E5F31D3D918500D1BF90 /* SUCodeSigningVerifier.m in Sources */, @@ -2755,6 +2766,7 @@ 7246E0A41C83B685003B4E75 /* SUStandardUpdaterController.m in Sources */, 725F977C1C8A896F00265BE4 /* SUUserDriverCoreComponent.m in Sources */, 61B5FCDE09C52A9F00B25A18 /* SUUpdateAlert.m in Sources */, + 7267E5FE1D3DD1B700D1BF90 /* SUDownloadedUpdate.m in Sources */, 612DCBB00D488BC60015DBEA /* SUUpdatePermissionPrompt.m in Sources */, 61B5F8EE09C4CE3C00B25A18 /* SUUpdater.m in Sources */, 72B767CB1C9B707000A07552 /* SUAppcastDriver.m in Sources */, diff --git a/Sparkle/SUCoreBasedUpdateDriver.m b/Sparkle/SUCoreBasedUpdateDriver.m index 7b8db88d..0a7ee5de 100644 --- a/Sparkle/SUCoreBasedUpdateDriver.m +++ b/Sparkle/SUCoreBasedUpdateDriver.m @@ -15,6 +15,7 @@ #import "SULocalCacheDirectory.h" #import "SULog.h" #import "SUErrors.h" +#import "SUDownloadedUpdate.h" #ifdef _APPKITDEFINES_H #error This is a "core" class and should NOT import AppKit @@ -134,20 +135,14 @@ } } -- (void)downloadDriverDidDownloadUpdate +- (void)downloadDriverDidDownloadUpdate:(SUDownloadedUpdate *)downloadedUpdate { // Now we have to extract the downloaded archive. if ([self.delegate respondsToSelector:@selector(coreDriverDidFinishDownloadingUpdate)]) { [self.delegate coreDriverDidFinishDownloadingUpdate]; } - NSString *downloadName = self.downloadDriver.downloadName; - assert(downloadName != nil); - - NSString *temporaryDirectory = self.downloadDriver.temporaryDirectory; - assert(temporaryDirectory != nil); - - [self.installerDriver extractDownloadName:downloadName withUpdateItem:self.updateItem temporaryDirectory:temporaryDirectory completion:^(NSError * _Nullable error) { + [self.installerDriver extractDownloadedUpdate:downloadedUpdate completion:^(NSError * _Nullable error) { if (error != nil) { [self.delegate coreDriverIsRequestingAbortUpdateWithError:(error.code == SUInstallationCancelledError) ? nil : error]; } diff --git a/Sparkle/SUDownloadDriver.h b/Sparkle/SUDownloadDriver.h index cecc3a11..a38c0867 100644 --- a/Sparkle/SUDownloadDriver.h +++ b/Sparkle/SUDownloadDriver.h @@ -10,6 +10,8 @@ NS_ASSUME_NONNULL_BEGIN +@class SUAppcastItem, SUHost, SUDownloadedUpdate; + @protocol SUDownloadDriverDelegate - (void)downloadDriverWillBeginDownload; @@ -18,14 +20,12 @@ NS_ASSUME_NONNULL_BEGIN - (void)downloadDriverDidReceiveDataOfLength:(NSUInteger)length; -- (void)downloadDriverDidDownloadUpdate; +- (void)downloadDriverDidDownloadUpdate:(SUDownloadedUpdate *)downloadedUpdate; - (void)downloadDriverDidFailToDownloadUpdateWithError:(NSError *)error; @end -@class SUAppcastItem, SUHost; - @interface SUDownloadDriver : NSObject - (instancetype)initWithUpdateItem:(SUAppcastItem *)updateItem host:(SUHost *)host userAgent:(NSString *)userAgent delegate:(id)delegate; @@ -33,8 +33,6 @@ NS_ASSUME_NONNULL_BEGIN - (void)downloadUpdate; @property (nonatomic, readonly) NSMutableURLRequest *request; -@property (nullable, nonatomic, readonly, copy) NSString *temporaryDirectory; -@property (nullable, nonatomic, readonly, copy) NSString *downloadName; - (void)cleanup; diff --git a/Sparkle/SUDownloadDriver.m b/Sparkle/SUDownloadDriver.m index 531202f2..2fd87827 100644 --- a/Sparkle/SUDownloadDriver.m +++ b/Sparkle/SUDownloadDriver.m @@ -17,6 +17,7 @@ #import "SULog.h" #import "SUErrors.h" #import "SUURLRequest.h" +#import "SUDownloadedUpdate.h" #ifdef _APPKITDEFINES_H #error This is a "core" class and should NOT import AppKit @@ -148,7 +149,9 @@ SULog(@"Warning: Downloader's expected content length (%lu) != Appcast item's length (%lu)", self.expectedContentLength, self.updateItem.contentLength); } - [self.delegate downloadDriverDidDownloadUpdate]; + SUDownloadedUpdate *downloadedUpdate = [[SUDownloadedUpdate alloc] initWithAppcastItem:self.updateItem downloadName:self.downloadName temporaryDirectory:self.temporaryDirectory]; + + [self.delegate downloadDriverDidDownloadUpdate:downloadedUpdate]; [self cleanup]; }); } diff --git a/Sparkle/SUDownloadedUpdate.h b/Sparkle/SUDownloadedUpdate.h new file mode 100644 index 00000000..fd729dae --- /dev/null +++ b/Sparkle/SUDownloadedUpdate.h @@ -0,0 +1,25 @@ +// +// SUDownloadedUpdate.h +// Sparkle +// +// Created by Mayur Pawashe on 7/18/16. +// Copyright © 2016 Sparkle Project. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class SUAppcastItem; + +@interface SUDownloadedUpdate : NSObject + +- (instancetype)initWithAppcastItem:(SUAppcastItem *)updateItem downloadName:(NSString *)downloadName temporaryDirectory:(NSString *)temporaryDirectory; + +@property (nonatomic, readonly) SUAppcastItem *updateItem; +@property (nonatomic, copy, readonly) NSString *downloadName; +@property (nonatomic, copy, readonly) NSString *temporaryDirectory; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Sparkle/SUDownloadedUpdate.m b/Sparkle/SUDownloadedUpdate.m new file mode 100644 index 00000000..2d7577bb --- /dev/null +++ b/Sparkle/SUDownloadedUpdate.m @@ -0,0 +1,28 @@ +// +// SUDownloadedUpdate.m +// Sparkle +// +// Created by Mayur Pawashe on 7/18/16. +// Copyright © 2016 Sparkle Project. All rights reserved. +// + +#import "SUDownloadedUpdate.h" + +@implementation SUDownloadedUpdate + +@synthesize updateItem = _updateItem; +@synthesize downloadName = _downloadName; +@synthesize temporaryDirectory = _temporaryDirectory; + +- (instancetype)initWithAppcastItem:(SUAppcastItem *)updateItem downloadName:(NSString *)downloadName temporaryDirectory:(NSString *)temporaryDirectory +{ + self = [super init]; + if (self != nil) { + _updateItem = updateItem; + _downloadName = [downloadName copy]; + _temporaryDirectory = [temporaryDirectory copy]; + } + return self; +} + +@end diff --git a/Sparkle/SUInstallerDriver.h b/Sparkle/SUInstallerDriver.h index f0fd63fe..f804cbef 100644 --- a/Sparkle/SUInstallerDriver.h +++ b/Sparkle/SUInstallerDriver.h @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol SUUpdaterDelegate; -@class SUHost, SUAppcastItem; +@class SUHost, SUAppcastItem, SUDownloadedUpdate; @protocol SUInstallerDriverDelegate @@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)resumeUpdateWithUpdateItem:(SUAppcastItem *)updateItem; -- (void)extractDownloadName:(NSString *)downloadName withUpdateItem:(SUAppcastItem *)updateItem temporaryDirectory:(NSString *)temporaryDirectory completion:(void (^)(NSError * _Nullable))completionHandler; +- (void)extractDownloadedUpdate:(SUDownloadedUpdate *)downloadedUpdate completion:(void (^)(NSError * _Nullable))completionHandler; - (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI; diff --git a/Sparkle/SUInstallerDriver.m b/Sparkle/SUInstallerDriver.m index 146c7e96..864893cd 100644 --- a/Sparkle/SUInstallerDriver.m +++ b/Sparkle/SUInstallerDriver.m @@ -24,6 +24,7 @@ #import "SUInstallerConnection.h" #import "SUInstallerConnectionProtocol.h" #import "SUXPCInstallerConnection.h" +#import "SUDownloadedUpdate.h" #ifdef _APPKITDEFINES_H #error This is a "core" class and should NOT import AppKit @@ -129,11 +130,11 @@ } // This can be called multiple times (eg: if a delta update fails, this may be called again with a regular update item) -- (void)extractDownloadName:(NSString *)downloadName withUpdateItem:(SUAppcastItem *)updateItem temporaryDirectory:(NSString *)temporaryDirectory completion:(void (^)(NSError * _Nullable))completionHandler +- (void)extractDownloadedUpdate:(SUDownloadedUpdate *)downloadedUpdate completion:(void (^)(NSError * _Nullable))completionHandler { - self.updateItem = updateItem; - self.temporaryDirectory = temporaryDirectory; - self.downloadName = downloadName; + self.updateItem = downloadedUpdate.updateItem; + self.temporaryDirectory = downloadedUpdate.temporaryDirectory; + self.downloadName = downloadedUpdate.downloadName; self.currentStage = SUInstallerNotStarted;