Compare commits

..
2 Commits
26 changed files with 120 additions and 164 deletions

No files matched your search

+3 -3
View File
@@ -71,7 +71,7 @@ jobs:
run: | run: |
git config user.name Sparkle-Bot git config user.name Sparkle-Bot
git config user.email sparkle.project.bot@gmail.com git config user.email sparkle.project.bot@gmail.com
git tag "${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}" git tag "${{ github.event.inputs.marketingVersion }}"
- name: "Build release distribution" - name: "Build release distribution"
run: make release run: make release
@@ -90,8 +90,8 @@ jobs:
with: with:
draft: true draft: true
prerelease: ${{ env.PRERELEASE_VERSION }} prerelease: ${{ env.PRERELEASE_VERSION }}
name: "Sparkle ${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}" name: "Sparkle ${{ github.event.inputs.marketingVersion }}"
tag_name: "${{ github.event.inputs.marketingVersion }}${{ github.event.inputs.prereleaseSuffix }}" tag_name: ${{ github.event.inputs.marketingVersion }}
fail_on_unmatched_files: true fail_on_unmatched_files: true
token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }} token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }}
body_path: latest-changes.txt body_path: latest-changes.txt
+1 -12
View File
@@ -1,20 +1,9 @@
# 1.27.3
* Create and use temp extraction directory in generate_appcast again (#2556) (Zorg)
# 1.27.2
* Extract archives in a separate directory from the input archive (#2552) (Zorg)
* Fix incorrect xz log warning in make release (#2044) (trss)
# 1.27.1 # 1.27.1
* Use px instead of pt when specifying font size to fix default font size in WebView from #1962 (regressed in 1.25.0 with WKWebView adoption) (Daniel Jalkut) * Use px instead of pt when specifying font size to fix default font size in WebView from #1962 (regressed in 1.25.0 with WKWebView adoption) (Daniel Jalkut)
* Fix to prevent Sparkle manipulating the host app's high level WebView defaults from #1961 (affecting only macOS versions before 10.11 in 1.x branch) (Daniel Jalkut) * Fix to prevent Sparkle manipulating the host app's high level WebView defaults from #1961 (affecting only macOS versions before 10.11 in 1.x branch) (Daniel Jalkut)
* Add safer handling of applying binary delta files from #1990 (Zorg) * Add safer handling of applying binary delta files from #1990 (Zorg)
* Don't use current date unless necessary when scheduling next update from #1991 (Zorg) * Don't use current date unless necessary when scheduling next update to be more resilient against rapid polling from #1991 (Zorg)
* Whitelist about:srcdoc as a safe web URL from #1938, #2007 (Louis Pontoise, Zorg)
* Backport not hiding update window on deactivation from #2008 (Zorg)
# 1.27.0 # 1.27.0
+3 -3
View File
@@ -19,13 +19,13 @@ SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
// These variables must have a space after the '=' too // These variables must have a space after the '=' too
SPARKLE_VERSION_MAJOR = 1 SPARKLE_VERSION_MAJOR = 1
SPARKLE_VERSION_MINOR = 27 SPARKLE_VERSION_MINOR = 27
SPARKLE_VERSION_PATCH = 3 SPARKLE_VERSION_PATCH = 1
// This should be in SemVer format or empty, ie. "-rc.1" // This should be in SemVer format or empty, ie. "-rc.1"
// These variables must have a space after the '=' too // These variables must have a space after the '=' too
SPARKLE_VERSION_SUFFIX = SPARKLE_VERSION_SUFFIX = -rc.1
// This is now a monotonically increasing ID number, even across prereleases, but let's keep this below 2.0 // This is now a monotonically increasing ID number, even across prereleases, but let's keep this below 2.0
CURRENT_PROJECT_VERSION = 1.108 CURRENT_PROJECT_VERSION = 1.103
MARKETING_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)$(SPARKLE_VERSION_SUFFIX) MARKETING_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)$(SPARKLE_VERSION_SUFFIX)
+7 -7
View File
@@ -55,13 +55,13 @@ if [ "$ACTION" = "" ] ; then
cp -R "$CONFIGURATION_BUILD_DIR/staging/bin" "$CONFIGURATION_BUILD_DIR/staging-spm" cp -R "$CONFIGURATION_BUILD_DIR/staging/bin" "$CONFIGURATION_BUILD_DIR/staging-spm"
cd "$CONFIGURATION_BUILD_DIR/staging" cd "$CONFIGURATION_BUILD_DIR/staging"
if [ -x "$(command -v xz)" ]; then if [ -x "$(command -v xz)" ]; then
XZ_EXISTS=1 XZ_EXISTS=1
else else
XZ_EXISTS=0 XZ_EXISTS=0
fi fi
rm -rf "/tmp/sparkle-extract" rm -rf "/tmp/sparkle-extract"
mkdir -p "/tmp/sparkle-extract" mkdir -p "/tmp/sparkle-extract"
@@ -88,7 +88,7 @@ if [ "$ACTION" = "" ] ; then
rm -rf "/tmp/sparkle-extract" rm -rf "/tmp/sparkle-extract"
rm -rf "$CONFIGURATION_BUILD_DIR/staging" rm -rf "$CONFIGURATION_BUILD_DIR/staging"
# Generate zip containing the xcframework for SPM # Generate zip containing the xcframework for SPM
rm -rf "/tmp/sparkle-spm-extract" rm -rf "/tmp/sparkle-spm-extract"
mkdir -p "/tmp/sparkle-spm-extract" mkdir -p "/tmp/sparkle-spm-extract"
@@ -100,7 +100,7 @@ if [ "$ACTION" = "" ] ; then
# This guards against our archives being corrupt / created incorrectly # This guards against our archives being corrupt / created incorrectly
ditto -x -k "../Sparkle-for-Swift-Package-Manager.zip" "/tmp/sparkle-spm-extract" ditto -x -k "../Sparkle-for-Swift-Package-Manager.zip" "/tmp/sparkle-spm-extract"
verify_code_signatures "/tmp/sparkle-spm-extract" verify_code_signatures "/tmp/sparkle-spm-extract"
rm -rf "/tmp/sparkle-spm-extract" rm -rf "/tmp/sparkle-spm-extract"
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm" rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
@@ -138,10 +138,10 @@ if [ "$ACTION" = "" ] ; then
else else
echo "warning: Xcode version $XCODE_VERSION_ACTUAL does not support computing checksums for Swift Packages. Please update the Package manifest manually." echo "warning: Xcode version $XCODE_VERSION_ACTUAL does not support computing checksums for Swift Packages. Please update the Package manifest manually."
fi fi
if [ "$XZ_EXISTS" -ne 1 ] ; then if [ "$XZ_EXISTS" -eq 1 ] ; then
echo "WARNING: xz compression is used for official releases but bz2 is being used instead because xz tool is not installed on your system." echo "WARNING: xz compression is used for official releases but bz2 is being used instead because xz tool is not installed on your system."
fi fi
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm" rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
fi fi
+3 -3
View File
@@ -2,10 +2,10 @@
import PackageDescription import PackageDescription
// Version is technically not required here, SPM doesn't check // Version is technically not required here, SPM doesn't check
let version = "1.27.3" let version = "1.27.1-rc.1"
// Tag is required to point towards the right asset. SPM requires the tag to follow semantic versioning to be able to resolve it. // Tag is required to point towards the right asset. SPM requires the tag to follow semantic versioning to be able to resolve it.
let tag = "1.27.3" let tag = "1.27.1-rc.1"
let checksum = "f0c6b4e6ffc6269a67b0d4ff254e3e8acfc6b3852db7b9957d4c0a5b39044446" let checksum = "29ea21aff129265413ca48785eacd4823cea89670299675069d36c41fd0a33e9"
let url = "https://github.com/sparkle-project/Sparkle/releases/download/\(tag)/Sparkle-for-Swift-Package-Manager.zip" let url = "https://github.com/sparkle-project/Sparkle/releases/download/\(tag)/Sparkle-for-Swift-Package-Manager.zip"
let package = Package( let package = Package(
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "Sparkle" s.name = "Sparkle"
s.version = "1.27.3" s.version = "1.27.1-rc.1"
s.summary = "A software update framework for macOS" s.summary = "A software update framework for macOS"
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers." s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
s.homepage = "https://sparkle-project.org" s.homepage = "https://sparkle-project.org"
+3 -3
View File
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19455" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies> <dependencies>
<deployment identifier="macosx"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19455"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
@@ -16,7 +16,7 @@
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SUAutomaticUpdateAlert" animationBehavior="default" id="5" userLabel="Window"> <window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SUAutomaticUpdateAlert" animationBehavior="default" id="5" userLabel="Window" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES"/> <windowStyleMask key="styleMask" titled="YES"/>
<windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/> <windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+1 -1
View File
@@ -20,7 +20,7 @@
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window identifier="SUUpdateAlert" title="Software Update" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SUUpdateAlert" animationBehavior="default" id="5" userLabel="Update Alert (release notes)"> <window identifier="SUUpdateAlert" title="Software Update" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SUUpdateAlert" animationBehavior="default" id="5" userLabel="Update Alert (release notes)" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/> <windowCollectionBehavior key="collectionBehavior" fullScreenAuxiliary="YES"/>
<windowPositionMask key="initialPositionMask" topStrut="YES" bottomStrut="YES"/> <windowPositionMask key="initialPositionMask" topStrut="YES" bottomStrut="YES"/>
+1 -1
View File
@@ -19,7 +19,7 @@
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="5" userLabel="Profile Info"> <window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="5" userLabel="Profile Info" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES"/> <windowStyleMask key="styleMask" titled="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="83" y="492" width="438" height="168"/> <rect key="contentRect" x="83" y="492" width="438" height="168"/>
+14 -27
View File
@@ -30,7 +30,6 @@
#import "SPUURLRequest.h" #import "SPUURLRequest.h"
#import "SPUDownloaderSession.h" #import "SPUDownloaderSession.h"
#import "SPULocalCacheDirectory.h"
@interface SUBasicUpdateDriver () @interface SUBasicUpdateDriver ()
@@ -39,7 +38,6 @@
@property (assign) NSComparisonResult latestAppcastItemComparisonResult; @property (assign) NSComparisonResult latestAppcastItemComparisonResult;
@property (strong) SPUDownloader *download; @property (strong) SPUDownloader *download;
@property (copy) NSString *downloadPath; @property (copy) NSString *downloadPath;
@property (copy) NSString *extractionDirectory;
@property (strong) SUAppcastItem *nonDeltaUpdateItem; @property (strong) SUAppcastItem *nonDeltaUpdateItem;
@property (copy) NSString *tempDir; @property (copy) NSString *tempDir;
@@ -56,7 +54,6 @@
@synthesize latestAppcastItemComparisonResult; @synthesize latestAppcastItemComparisonResult;
@synthesize download; @synthesize download;
@synthesize downloadPath; @synthesize downloadPath;
@synthesize extractionDirectory = _extractionDirectory;
@synthesize nonDeltaUpdateItem; @synthesize nonDeltaUpdateItem;
@synthesize tempDir; @synthesize tempDir;
@@ -386,7 +383,6 @@
{ {
self.tempDir = temporaryDirectory; self.tempDir = temporaryDirectory;
self.downloadPath = [temporaryDirectory stringByAppendingPathComponent:destinationName]; self.downloadPath = [temporaryDirectory stringByAppendingPathComponent:destinationName];
self.extractionDirectory = [SPULocalCacheDirectory createUniqueDirectoryInDirectory:temporaryDirectory];
} }
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)__unused expectedContentLength - (void)downloaderDidReceiveExpectedContentLength:(int64_t)__unused expectedContentLength
@@ -445,30 +441,22 @@
- (void)extractUpdate - (void)extractUpdate
{ {
BOOL success = NO;
id<SUUpdaterPrivate> updater = self.updater; id<SUUpdaterPrivate> updater = self.updater;
id<SUUnarchiverProtocol> unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:self.host.bundlePath decryptionPassword:updater.decryptionPassword];
id<SUUnarchiverProtocol> unarchiver;
if (self.extractionDirectory == nil) { BOOL success = NO;
SULog(SULogLevelError, @"Error: Failed to create temporary extraction directory for %@!", self.downloadPath); if (!unarchiver) {
unarchiver = nil; SULog(SULogLevelError, @"Error: No valid unarchiver for %@!", self.downloadPath);
} else { } else {
unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath extractionDirectory:self.extractionDirectory updatingHostBundlePath:self.host.bundlePath decryptionPassword:updater.decryptionPassword]; self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath signatures:self.updateItem.signatures host:self.host];
if (!unarchiver) { // Currently unsafe archives are the only case where we can prevalidate before extraction, but that could change in the future
SULog(SULogLevelError, @"Error: No valid unarchiver for %@!", self.downloadPath); BOOL needsPrevalidation = [[unarchiver class] mustValidateBeforeExtraction];
if (needsPrevalidation) {
success = [self.updateValidator validateDownloadPath];
} else { } else {
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath signatures:self.updateItem.signatures host:self.host]; success = YES;
// Currently unsafe archives are the only case where we can prevalidate before extraction, but that could change in the future
BOOL needsPrevalidation = [[unarchiver class] mustValidateBeforeExtraction];
if (needsPrevalidation) {
success = [self.updateValidator validateDownloadPath];
} else {
success = YES;
}
} }
} }
@@ -572,9 +560,8 @@
{ {
assert(self.updateItem); assert(self.updateItem);
assert(self.updateValidator); assert(self.updateValidator);
assert(self.extractionDirectory);
BOOL validationCheckSuccess = [self.updateValidator validateWithUpdateDirectory:self.extractionDirectory]; BOOL validationCheckSuccess = [self.updateValidator validateWithUpdateDirectory:self.tempDir];
if (!validationCheckSuccess) { if (!validationCheckSuccess) {
NSDictionary *userInfo = @{ NSDictionary *userInfo = @{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil), NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
+1 -1
View File
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface SUBinaryDeltaUnarchiver : NSObject <SUUnarchiverProtocol> @interface SUBinaryDeltaUnarchiver : NSObject <SUUnarchiverProtocol>
- (instancetype)initWithArchivePath:(NSString *)archivePath extractionDirectory:(NSString *)extractionDirectory updateHostBundlePath:(NSString *)updateHostBundlePath; - (instancetype)initWithArchivePath:(NSString *)archivePath updateHostBundlePath:(NSString *)updateHostBundlePath;
@end @end
+2 -5
View File
@@ -20,7 +20,6 @@
@property (nonatomic, copy, readonly) NSString *archivePath; @property (nonatomic, copy, readonly) NSString *archivePath;
@property (nonatomic, copy, readonly) NSString *updateHostBundlePath; @property (nonatomic, copy, readonly) NSString *updateHostBundlePath;
@property (nonatomic, copy, readonly) NSString *extractionDirectory;
@end @end
@@ -28,7 +27,6 @@
@synthesize archivePath = _archivePath; @synthesize archivePath = _archivePath;
@synthesize updateHostBundlePath = _updateHostBundlePath; @synthesize updateHostBundlePath = _updateHostBundlePath;
@synthesize extractionDirectory = _extractionDirectory;
+ (BOOL)canUnarchivePath:(NSString *)path + (BOOL)canUnarchivePath:(NSString *)path
{ {
@@ -75,13 +73,12 @@
} }
} }
- (instancetype)initWithArchivePath:(NSString *)archivePath extractionDirectory:(NSString *)extractionDirectory updateHostBundlePath:(NSString *)updateHostBundlePath - (instancetype)initWithArchivePath:(NSString *)archivePath updateHostBundlePath:(NSString *)updateHostBundlePath
{ {
self = [super init]; self = [super init];
if (self != nil) { if (self != nil) {
_archivePath = [archivePath copy]; _archivePath = [archivePath copy];
_updateHostBundlePath = [updateHostBundlePath copy]; _updateHostBundlePath = [updateHostBundlePath copy];
_extractionDirectory = [extractionDirectory copy];
} }
return self; return self;
} }
@@ -99,7 +96,7 @@
- (void)extractDeltaWithNotifier:(SUUnarchiverNotifier *)notifier - (void)extractDeltaWithNotifier:(SUUnarchiverNotifier *)notifier
{ {
NSString *sourcePath = self.updateHostBundlePath; NSString *sourcePath = self.updateHostBundlePath;
NSString *targetPath = [self.extractionDirectory stringByAppendingPathComponent:[sourcePath lastPathComponent]]; NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
NSError *applyDiffError = nil; NSError *applyDiffError = nil;
BOOL success = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO, ^(double progress){ BOOL success = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO, ^(double progress){
+1 -1
View File
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface SUDiskImageUnarchiver : NSObject <SUUnarchiverProtocol> @interface SUDiskImageUnarchiver : NSObject <SUUnarchiverProtocol>
- (instancetype)initWithArchivePath:(NSString *)archivePath extractionDirectory:(NSString *)extractionDirectory decryptionPassword:(nullable NSString *)decryptionPassword; - (instancetype)initWithArchivePath:(NSString *)archivePath decryptionPassword:(nullable NSString *)decryptionPassword;
@end @end
+2 -5
View File
@@ -17,7 +17,6 @@
@property (nonatomic, copy, readonly) NSString *archivePath; @property (nonatomic, copy, readonly) NSString *archivePath;
@property (nullable, nonatomic, copy, readonly) NSString *decryptionPassword; @property (nullable, nonatomic, copy, readonly) NSString *decryptionPassword;
@property (nonatomic, copy, readonly) NSString *extractionDirectory;
@end @end
@@ -25,7 +24,6 @@
@synthesize archivePath = _archivePath; @synthesize archivePath = _archivePath;
@synthesize decryptionPassword = _decryptionPassword; @synthesize decryptionPassword = _decryptionPassword;
@synthesize extractionDirectory = _extractionDirectory;
+ (BOOL)canUnarchivePath:(NSString *)path + (BOOL)canUnarchivePath:(NSString *)path
{ {
@@ -37,13 +35,12 @@
return NO; return NO;
} }
- (instancetype)initWithArchivePath:(NSString *)archivePath extractionDirectory:(NSString *)extractionDirectory decryptionPassword:(nullable NSString *)decryptionPassword - (instancetype)initWithArchivePath:(NSString *)archivePath decryptionPassword:(nullable NSString *)decryptionPassword
{ {
self = [super init]; self = [super init];
if (self != nil) { if (self != nil) {
_archivePath = [archivePath copy]; _archivePath = [archivePath copy];
_decryptionPassword = [decryptionPassword copy]; _decryptionPassword = [decryptionPassword copy];
_extractionDirectory = [extractionDirectory copy];
} }
return self; return self;
} }
@@ -161,7 +158,7 @@
for (NSString *item in contents) for (NSString *item in contents)
{ {
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item]; NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
NSString *toPath = [self.extractionDirectory stringByAppendingPathComponent:item]; NSString *toPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
// We skip any files in the DMG which are not readable. // We skip any files in the DMG which are not readable.
if (![manager isReadableFileAtPath:fromPath]) { if (![manager isReadableFileAtPath:fromPath]) {
+1 -1
View File
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
// An unarchiver for flat packages that doesn't really do any unarchiving // An unarchiver for flat packages that doesn't really do any unarchiving
@interface SUFlatPackageUnarchiver : NSObject <SUUnarchiverProtocol> @interface SUFlatPackageUnarchiver : NSObject <SUUnarchiverProtocol>
- (instancetype)initWithFlatPackagePath:(NSString *)flatPackagePath extractionDirectory:(NSString *)extractionDirectory; - (instancetype)initWithFlatPackagePath:(NSString *)flatPackagePath;
@end @end
+3 -18
View File
@@ -16,14 +16,12 @@
@interface SUFlatPackageUnarchiver () @interface SUFlatPackageUnarchiver ()
@property (nonatomic, readonly) NSString *flatPackagePath; @property (nonatomic, readonly) NSString *flatPackagePath;
@property (nonatomic, readonly, copy) NSString *extractionDirectory;
@end @end
@implementation SUFlatPackageUnarchiver @implementation SUFlatPackageUnarchiver
@synthesize flatPackagePath = _flatPackagePath; @synthesize flatPackagePath = _flatPackagePath;
@synthesize extractionDirectory = _extractionDirectory;
+ (BOOL)canUnarchivePath:(NSString *)path + (BOOL)canUnarchivePath:(NSString *)path
{ {
@@ -36,12 +34,11 @@
return NO; return NO;
} }
- (instancetype)initWithFlatPackagePath:(NSString *)flatPackagePath extractionDirectory:(NSString *)extractionDirectory - (instancetype)initWithFlatPackagePath:(NSString *)flatPackagePath;
{ {
self = [super init]; self = [super init];
if (self != nil) { if (self != nil) {
_flatPackagePath = [flatPackagePath copy]; _flatPackagePath = [flatPackagePath copy];
_extractionDirectory = [extractionDirectory copy];
} }
return self; return self;
} }
@@ -57,20 +54,8 @@
} else if (![[NSFileManager defaultManager] fileExistsAtPath:self.flatPackagePath isDirectory:&isDirectory] || isDirectory) { } else if (![[NSFileManager defaultManager] fileExistsAtPath:self.flatPackagePath isDirectory:&isDirectory] || isDirectory) {
[notifier notifyFailureWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Flat package does not exist at %@", self.flatPackagePath]}]]; [notifier notifyFailureWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Flat package does not exist at %@", self.flatPackagePath]}]];
} else { } else {
// Copying the flat package should be very fast, especially on APFS [notifier notifyProgress:1.0];
NSError *copyError = nil; [notifier notifySuccess];
if (![[NSFileManager defaultManager] copyItemAtPath:self.flatPackagePath toPath:[self.extractionDirectory stringByAppendingPathComponent:self.flatPackagePath.lastPathComponent] error:&copyError]) {
NSMutableDictionary *userInfoDictionary = [NSMutableDictionary dictionaryWithDictionary:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Flat package (%@) cannot be copied to extraction directory (%@)", self.flatPackagePath, self.extractionDirectory]}];
if (copyError != nil) {
userInfoDictionary[NSUnderlyingErrorKey] = copyError;
}
[notifier notifyFailureWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:userInfoDictionary]];
} else {
[notifier notifyProgress:1.0];
[notifier notifySuccess];
}
} }
} }
+13 -28
View File
@@ -20,6 +20,15 @@
@implementation SUInstaller @implementation SUInstaller
+ (BOOL)isAliasFolderAtPath:(NSString *)path
{
NSNumber *aliasFlag = nil;
[[NSURL fileURLWithPath:path] getResourceValue:&aliasFlag forKey:NSURLIsAliasFileKey error:nil];
NSNumber *directoryFlag = nil;
[[NSURL fileURLWithPath:path] getResourceValue:&directoryFlag forKey:NSURLIsDirectoryKey error:nil];
return aliasFlag.boolValue && directoryFlag.boolValue;
}
+ (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(nullable BOOL *)isGuidedPtr + (nullable NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(nullable BOOL *)isGuidedPtr
{ {
NSParameterAssert(inUpdateFolder); NSParameterAssert(inUpdateFolder);
@@ -38,34 +47,6 @@
while ((currentFile = [dirEnum nextObject])) { while ((currentFile = [dirEnum nextObject])) {
NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile]; NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile];
// Ignore all symbolic links and aliases
{
NSURL *currentPathURL = [NSURL fileURLWithPath:currentPath];
NSNumber *symbolicLinkFlag = nil;
[currentPathURL getResourceValue:&symbolicLinkFlag forKey:NSURLIsSymbolicLinkKey error:NULL];
if (symbolicLinkFlag.boolValue) {
// NSDirectoryEnumerator won't recurse into symlinked directories
continue;
}
NSNumber *aliasFlag = nil;
[currentPathURL getResourceValue:&aliasFlag forKey:NSURLIsAliasFileKey error:NULL];
if (aliasFlag.boolValue) {
NSNumber *directoryFlag = nil;
[currentPathURL getResourceValue:&directoryFlag forKey:NSURLIsDirectoryKey error:NULL];
// Some DMGs have symlinks into /Applications! That's no good!
if (directoryFlag.boolValue) {
[dirEnum skipDescendents];
}
continue;
}
}
NSString *currentFilename = [currentFile lastPathComponent]; NSString *currentFilename = [currentFile lastPathComponent];
NSString *currentExtension = [currentFile pathExtension]; NSString *currentExtension = [currentFile pathExtension];
NSString *currentFilenameNoExtension = [currentFilename stringByDeletingPathExtension]; NSString *currentFilenameNoExtension = [currentFilename stringByDeletingPathExtension];
@@ -95,6 +76,10 @@
break; break;
} }
} }
// Some DMGs have symlinks into /Applications! That's no good!
if ([self isAliasFolderAtPath:currentPath])
[dirEnum skipDescendents];
} }
// We don't have a valid path. Try to use the fallback package. // We don't have a valid path. Try to use the fallback package.
+1 -1
View File
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface SUPipedUnarchiver : NSObject <SUUnarchiverProtocol> @interface SUPipedUnarchiver : NSObject <SUUnarchiverProtocol>
- (instancetype)initWithArchivePath:(NSString *)archivePath extractionDirectory:(NSString *)extractionDirectory; - (instancetype)initWithArchivePath:(NSString *)archivePath;
@end @end
+2 -5
View File
@@ -17,14 +17,12 @@
@interface SUPipedUnarchiver () @interface SUPipedUnarchiver ()
@property (nonatomic, copy, readonly) NSString *archivePath; @property (nonatomic, copy, readonly) NSString *archivePath;
@property (nonatomic, copy, readonly) NSString *extractionDirectory;
@end @end
@implementation SUPipedUnarchiver @implementation SUPipedUnarchiver
@synthesize archivePath = _archivePath; @synthesize archivePath = _archivePath;
@synthesize extractionDirectory = _extractionDirectory;
+ (nullable NSArray <NSString *> *)commandAndArgumentsConformingToTypeOfPath:(NSString *)path + (nullable NSArray <NSString *> *)commandAndArgumentsConformingToTypeOfPath:(NSString *)path
{ {
@@ -65,12 +63,11 @@
return NO; return NO;
} }
- (instancetype)initWithArchivePath:(NSString *)archivePath extractionDirectory:(NSString *)extractionDirectory - (instancetype)initWithArchivePath:(NSString *)archivePath
{ {
self = [super init]; self = [super init];
if (self != nil) { if (self != nil) {
_archivePath = [archivePath copy]; _archivePath = [archivePath copy];
_extractionDirectory = [extractionDirectory copy];
} }
return self; return self;
} }
@@ -97,7 +94,7 @@
// *** GETS CALLED ON NON-MAIN THREAD!!! // *** GETS CALLED ON NON-MAIN THREAD!!!
@autoreleasepool { @autoreleasepool {
NSError *error = nil; NSError *error = nil;
NSString *destination = self.extractionDirectory; NSString *destination = [self.archivePath stringByDeletingLastPathComponent];
SULog(SULogLevelDefault, @"Extracting using '%@' '%@' < '%@' '%@'", command, [args componentsJoinedByString:@"' '"], self.archivePath, destination); SULog(SULogLevelDefault, @"Extracting using '%@' '%@' < '%@' '%@'", command, [args componentsJoinedByString:@"' '"], self.archivePath, destination);
+1 -1
View File
@@ -16,7 +16,7 @@
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window identifier="SUStatus" title="Set in Code" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="5" userLabel="Window"> <window identifier="SUStatus" title="Set in Code" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="5" userLabel="Window" customClass="NSPanel">
<windowStyleMask key="styleMask" titled="YES"/> <windowStyleMask key="styleMask" titled="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="200" y="222" width="400" height="107"/> <rect key="contentRect" x="200" y="222" width="400" height="107"/>
+1 -1
View File
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface SUUnarchiver : NSObject @interface SUUnarchiver : NSObject
+ (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path extractionDirectory:(NSString *)extractionDirectory updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword; + (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword;
@end @end
+6 -5
View File
@@ -18,20 +18,21 @@
@implementation SUUnarchiver @implementation SUUnarchiver
+ (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path extractionDirectory:(NSString *)extractionDirectory updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword + (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword
{ {
if ([SUPipedUnarchiver canUnarchivePath:path]) { if ([SUPipedUnarchiver canUnarchivePath:path]) {
return [[SUPipedUnarchiver alloc] initWithArchivePath:path extractionDirectory:extractionDirectory]; return [[SUPipedUnarchiver alloc] initWithArchivePath:path];
} else if ([SUDiskImageUnarchiver canUnarchivePath:path]) { } else if ([SUDiskImageUnarchiver canUnarchivePath:path]) {
return [[SUDiskImageUnarchiver alloc] initWithArchivePath:path extractionDirectory:extractionDirectory decryptionPassword:decryptionPassword]; return [[SUDiskImageUnarchiver alloc] initWithArchivePath:path decryptionPassword:decryptionPassword];
} else if ([SUBinaryDeltaUnarchiver canUnarchivePath:path]) { } else if ([SUBinaryDeltaUnarchiver canUnarchivePath:path]) {
assert(hostPath != nil); assert(hostPath != nil);
NSString *nonNullHostPath = hostPath; NSString *nonNullHostPath = hostPath;
return [[SUBinaryDeltaUnarchiver alloc] initWithArchivePath:path extractionDirectory:extractionDirectory updateHostBundlePath:nonNullHostPath]; return [[SUBinaryDeltaUnarchiver alloc] initWithArchivePath:path updateHostBundlePath:nonNullHostPath];
} else if ([SUFlatPackageUnarchiver canUnarchivePath:path]) { } else if ([SUFlatPackageUnarchiver canUnarchivePath:path]) {
return [[SUFlatPackageUnarchiver alloc] initWithFlatPackagePath:path extractionDirectory:extractionDirectory]; return [[SUFlatPackageUnarchiver alloc] initWithFlatPackagePath:path];
} }
return nil; return nil;
} }
+9 -9
View File
@@ -45,7 +45,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
- (instancetype)initForBundle:(NSBundle *)bundle; - (instancetype)initForBundle:(NSBundle *)bundle;
- (void)startUpdateCycle; - (void)startUpdateCycle;
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)updateDriver; - (void)checkForUpdatesWithDriver:(SUUpdateDriver *)updateDriver;
- (void)scheduleNextUpdateCheckUsingCurrentDate:(BOOL)usingCurrentDate; - (void)scheduleNextUpdateCheckUsingCurrentTime:(BOOL)usingCurrentTime;
- (void)registerAsObserver; - (void)registerAsObserver;
- (void)unregisterAsObserver; - (void)unregisterAsObserver;
- (void)updateDriverDidFinish:(NSNotification *)note; - (void)updateDriverDidFinish:(NSNotification *)note;
@@ -255,7 +255,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
// We start the update checks and register as observer for changes after the prompt finishes // We start the update checks and register as observer for changes after the prompt finishes
} else { } else {
// We check if the user's said they want updates, or they haven't said anything, and the default is set to checking. // We check if the user's said they want updates, or they haven't said anything, and the default is set to checking.
[self scheduleNextUpdateCheckUsingCurrentDate:YES]; [self scheduleNextUpdateCheckUsingCurrentTime:YES];
} }
} }
@@ -271,7 +271,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
{ {
self.driver = nil; self.driver = nil;
[self updateLastUpdateCheckDate]; [self updateLastUpdateCheckDate];
[self scheduleNextUpdateCheckUsingCurrentDate:NO]; [self scheduleNextUpdateCheckUsingCurrentTime:NO];
} }
} }
@@ -293,7 +293,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
[self didChangeValueForKey:@"lastUpdateCheckDate"]; [self didChangeValueForKey:@"lastUpdateCheckDate"];
} }
- (void)scheduleNextUpdateCheckUsingCurrentDate:(BOOL)usingCurrentDate - (void)scheduleNextUpdateCheckUsingCurrentTime:(BOOL)usingCurrentTime
{ {
if (self.checkTimer) if (self.checkTimer)
{ {
@@ -304,7 +304,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
// How long has it been since last we checked for an update? // How long has it been since last we checked for an update?
NSTimeInterval intervalSinceCheck; NSTimeInterval intervalSinceCheck;
if (usingCurrentDate) { if (usingCurrentTime) {
NSDate *lastCheckDate = [self lastUpdateCheckDate]; NSDate *lastCheckDate = [self lastUpdateCheckDate];
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; } if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate]; intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
@@ -344,7 +344,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (void)receiveWakeNote - (void)receiveWakeNote
{ {
if (self.shouldRescheduleOnWake) // the reason for rescheduling the update-check timer is that NSTimer does behave as if the time the Mac spends asleep did not exist at all, which can significantly prolong the time between update checks if (self.shouldRescheduleOnWake) // the reason for rescheduling the update-check timer is that NSTimer does behave as if the time the Mac spends asleep did not exist at all, which can significantly prolong the time between update checks
[self scheduleNextUpdateCheckUsingCurrentDate:YES]; [self scheduleNextUpdateCheckUsingCurrentTime:YES];
} }
- (void)checkForUpdatesInBackground - (void)checkForUpdatesInBackground
@@ -397,7 +397,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
if( [self.delegate respondsToSelector: @selector(updaterMayCheckForUpdates:)] && ![self.delegate updaterMayCheckForUpdates: self] ) if( [self.delegate respondsToSelector: @selector(updaterMayCheckForUpdates:)] && ![self.delegate updaterMayCheckForUpdates: self] )
{ {
[self scheduleNextUpdateCheckUsingCurrentDate:NO]; [self scheduleNextUpdateCheckUsingCurrentTime:NO];
return; return;
} }
@@ -406,7 +406,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
// If we're not given a driver at all, just schedule the next update check and bail. // If we're not given a driver at all, just schedule the next update check and bail.
if (!self.driver) if (!self.driver)
{ {
[self scheduleNextUpdateCheckUsingCurrentDate:NO]; [self scheduleNextUpdateCheckUsingCurrentTime:NO];
return; return;
} }
@@ -458,7 +458,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (void)resetUpdateCycle - (void)resetUpdateCycle
{ {
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil]; [[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil];
[self scheduleNextUpdateCheckUsingCurrentDate:YES]; [self scheduleNextUpdateCheckUsingCurrentTime:YES];
} }
- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyCheckForUpdates - (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyCheckForUpdates
+10 -4
View File
@@ -24,9 +24,10 @@ class SUUnarchiverTest: XCTestCase
let unarchivedSuccessExpectation = super.expectation(description: "Unarchived Success (format: \(archiveExtension))") let unarchivedSuccessExpectation = super.expectation(description: "Unarchived Success (format: \(archiveExtension))")
let unarchivedFailureExpectation = super.expectation(description: "Unarchived Failure (format: \(archiveExtension))") let unarchivedFailureExpectation = super.expectation(description: "Unarchived Failure (format: \(archiveExtension))")
let tempArchiveURL = tempDirectoryURL.appendingPathComponent(archiveResourceURL.lastPathComponent)
let extractedAppURL = tempDirectoryURL.appendingPathComponent(appName).appendingPathExtension("app") let extractedAppURL = tempDirectoryURL.appendingPathComponent(appName).appendingPathExtension("app")
self.unarchiveTestAppWithExtension(archiveExtension, appName: appName, tempDirectoryURL: tempDirectoryURL, archiveResourceURL: archiveResourceURL, password: password, expectingSuccess: expectingSuccess, testExpectation: unarchivedSuccessExpectation) self.unarchiveTestAppWithExtension(archiveExtension, appName: appName, tempDirectoryURL: tempDirectoryURL, tempArchiveURL: tempArchiveURL, archiveResourceURL: archiveResourceURL, password: password, expectingSuccess: expectingSuccess, testExpectation: unarchivedSuccessExpectation)
self.unarchiveNonExistentFileTestFailureAppWithExtension(archiveExtension, tempDirectoryURL: tempDirectoryURL, password: password, testExpectation: unarchivedFailureExpectation) self.unarchiveNonExistentFileTestFailureAppWithExtension(archiveExtension, tempDirectoryURL: tempDirectoryURL, password: password, testExpectation: unarchivedFailureExpectation)
super.waitForExpectations(timeout: 30.0, handler: nil) super.waitForExpectations(timeout: 30.0, handler: nil)
@@ -39,7 +40,7 @@ class SUUnarchiverTest: XCTestCase
func unarchiveNonExistentFileTestFailureAppWithExtension(_ archiveExtension: String, tempDirectoryURL: URL, password: String?, testExpectation: XCTestExpectation) { func unarchiveNonExistentFileTestFailureAppWithExtension(_ archiveExtension: String, tempDirectoryURL: URL, password: String?, testExpectation: XCTestExpectation) {
let tempArchiveURL = tempDirectoryURL.appendingPathComponent("error-invalid").appendingPathExtension(archiveExtension) let tempArchiveURL = tempDirectoryURL.appendingPathComponent("error-invalid").appendingPathExtension(archiveExtension)
let unarchiver = SUUnarchiver.unarchiver(forPath: tempArchiveURL.path, extractionDirectory: tempDirectoryURL.path, updatingHostBundlePath: nil, decryptionPassword: password)! let unarchiver = SUUnarchiver.unarchiver(forPath: tempArchiveURL.path, updatingHostBundlePath: nil, decryptionPassword: password)!
unarchiver.unarchive(completionBlock: {(error: Error?) -> Void in unarchiver.unarchive(completionBlock: {(error: Error?) -> Void in
XCTAssertNotNil(error) XCTAssertNotNil(error)
@@ -48,8 +49,13 @@ class SUUnarchiverTest: XCTestCase
} }
// swiftlint:disable function_parameter_count // swiftlint:disable function_parameter_count
func unarchiveTestAppWithExtension(_ archiveExtension: String, appName: String, tempDirectoryURL: URL, archiveResourceURL: URL, password: String?, expectingSuccess: Bool, testExpectation: XCTestExpectation) { func unarchiveTestAppWithExtension(_ archiveExtension: String, appName: String, tempDirectoryURL: URL, tempArchiveURL: URL, archiveResourceURL: URL, password: String?, expectingSuccess: Bool, testExpectation: XCTestExpectation) {
let unarchiver = SUUnarchiver.unarchiver(forPath: archiveResourceURL.path, extractionDirectory: tempDirectoryURL.path, updatingHostBundlePath: nil, decryptionPassword: password)!
let fileManager = FileManager.default
try! fileManager.copyItem(at: archiveResourceURL, to: tempArchiveURL)
let unarchiver = SUUnarchiver.unarchiver(forPath: tempArchiveURL.path, updatingHostBundlePath: nil, decryptionPassword: password)!
unarchiver.unarchive(completionBlock: {(error: Error?) -> Void in unarchiver.unarchive(completionBlock: {(error: Error?) -> Void in
if expectingSuccess { if expectingSuccess {
+2 -2
View File
@@ -47,12 +47,12 @@ class SUTestApplicationTest: XCTestCase
menuBarsQuery.menuBarItems["Sparkle Test App"].click() menuBarsQuery.menuBarItems["Sparkle Test App"].click()
} }
app.windows["SUUpdateAlert"].buttons["Install Update"].click() app.dialogs["SUUpdateAlert"].buttons["Install Update"].click()
// Give some time for the update to finish downloading / extracting // Give some time for the update to finish downloading / extracting
sleep(30) sleep(30)
app.windows["SUStatus"].buttons["Install and Relaunch"].click() app.dialogs["SUStatus"].buttons["Install and Relaunch"].click()
// Wait for the new updated app to finish launching so we can test if it's the frontmost app // Wait for the new updated app to finish launching so we can test if it's the frontmost app
sleep(10) sleep(10)
+28 -16
View File
@@ -8,26 +8,38 @@ import Foundation
func unarchive(itemPath: URL, archiveDestDir: URL, callback: @escaping (Error?) -> Void) { func unarchive(itemPath: URL, archiveDestDir: URL, callback: @escaping (Error?) -> Void) {
let fileManager = FileManager.default let fileManager = FileManager.default
let tempDir = archiveDestDir.appendingPathExtension("tmp") let tempDir = archiveDestDir.appendingPathExtension("tmp")
let itemCopy = tempDir.appendingPathComponent(itemPath.lastPathComponent)
_ = try? fileManager.removeItem(at: tempDir)
_ = try? fileManager.createDirectory(at: tempDir, withIntermediateDirectories: true, attributes: [:]) _ = try? fileManager.createDirectory(at: tempDir, withIntermediateDirectories: true, attributes: [:])
if let unarchiver = SUUnarchiver.unarchiver(forPath: itemPath.path, extractionDirectory: tempDir.path, updatingHostBundlePath: nil, decryptionPassword: nil) { do {
unarchiver.unarchive(completionBlock: { (error: Error?) in do {
if error != nil { try fileManager.linkItem(at: itemPath, to: itemCopy)
callback(error) } catch {
return try fileManager.copyItem(at: itemPath, to: itemCopy)
} }
if let unarchiver = SUUnarchiver.unarchiver(forPath: itemCopy.path, updatingHostBundlePath: nil, decryptionPassword: nil) {
unarchiver.unarchive(completionBlock: { (error: Error?) in
if error != nil {
callback(error)
return
}
do { _ = try? fileManager.removeItem(at: itemCopy)
try fileManager.moveItem(at: tempDir, to: archiveDestDir) do {
callback(nil) try fileManager.moveItem(at: tempDir, to: archiveDestDir)
} catch { callback(nil)
callback(error) } catch {
} callback(error)
}, progressBlock: nil) }
} else { }, progressBlock: nil)
callback(makeError(code: .unarchivingError, "Not a supported archive format: \(itemPath.path)")) } else {
_ = try? fileManager.removeItem(at: itemCopy)
callback(makeError(code: .unarchivingError, "Not a supported archive format: \(itemCopy)"))
}
} catch {
_ = try? fileManager.removeItem(at: tempDir)
callback(error)
} }
} }