mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-22 04:30:47 +00:00
Compare commits
10
Commits
1.27.1-rc.2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10d96f2b9b | ||
|
|
a9f370460a | ||
|
|
d7db589432 | ||
|
|
56ad4aa3c8 | ||
|
|
b5350bf58f | ||
|
|
bbe887e160 | ||
|
|
f453625573 | ||
|
|
7918c1c8fc | ||
|
|
4875f83bea | ||
|
|
43403a5068 |
No files matched your search
@@ -1,10 +1,18 @@
|
||||
# 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
|
||||
|
||||
* 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)
|
||||
* Add safer handling of applying binary delta files from #1990 (Zorg)
|
||||
* Don't use current date unless necessary when scheduling next update to be more resilient against rapid polling from #1991 (Zorg)
|
||||
* Prevent potential rapid update checks from sleep/wake events using a minimum monotonic delay from #2000 (Zorg)
|
||||
* Don't use current date unless necessary when scheduling next update 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)
|
||||
|
||||
|
||||
@@ -19,13 +19,13 @@ SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
|
||||
// These variables must have a space after the '=' too
|
||||
SPARKLE_VERSION_MAJOR = 1
|
||||
SPARKLE_VERSION_MINOR = 27
|
||||
SPARKLE_VERSION_PATCH = 1
|
||||
SPARKLE_VERSION_PATCH = 3
|
||||
|
||||
// This should be in SemVer format or empty, ie. "-rc.1"
|
||||
// These variables must have a space after the '=' too
|
||||
SPARKLE_VERSION_SUFFIX = -rc.2
|
||||
SPARKLE_VERSION_SUFFIX =
|
||||
// This is now a monotonically increasing ID number, even across prereleases, but let's keep this below 2.0
|
||||
CURRENT_PROJECT_VERSION = 1.105
|
||||
CURRENT_PROJECT_VERSION = 1.108
|
||||
|
||||
MARKETING_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)$(SPARKLE_VERSION_SUFFIX)
|
||||
|
||||
|
||||
@@ -55,13 +55,13 @@ if [ "$ACTION" = "" ] ; then
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/staging/bin" "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
|
||||
cd "$CONFIGURATION_BUILD_DIR/staging"
|
||||
|
||||
|
||||
if [ -x "$(command -v xz)" ]; then
|
||||
XZ_EXISTS=1
|
||||
else
|
||||
XZ_EXISTS=0
|
||||
fi
|
||||
|
||||
|
||||
rm -rf "/tmp/sparkle-extract"
|
||||
mkdir -p "/tmp/sparkle-extract"
|
||||
|
||||
@@ -88,7 +88,7 @@ if [ "$ACTION" = "" ] ; then
|
||||
|
||||
rm -rf "/tmp/sparkle-extract"
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
|
||||
|
||||
|
||||
# Generate zip containing the xcframework for SPM
|
||||
rm -rf "/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
|
||||
ditto -x -k "../Sparkle-for-Swift-Package-Manager.zip" "/tmp/sparkle-spm-extract"
|
||||
verify_code_signatures "/tmp/sparkle-spm-extract"
|
||||
|
||||
|
||||
rm -rf "/tmp/sparkle-spm-extract"
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
|
||||
@@ -138,10 +138,10 @@ if [ "$ACTION" = "" ] ; then
|
||||
else
|
||||
echo "warning: Xcode version $XCODE_VERSION_ACTUAL does not support computing checksums for Swift Packages. Please update the Package manifest manually."
|
||||
fi
|
||||
|
||||
if [ "$XZ_EXISTS" -eq 1 ] ; then
|
||||
|
||||
if [ "$XZ_EXISTS" -ne 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."
|
||||
fi
|
||||
|
||||
|
||||
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
|
||||
fi
|
||||
+3
-3
@@ -2,10 +2,10 @@
|
||||
import PackageDescription
|
||||
|
||||
// Version is technically not required here, SPM doesn't check
|
||||
let version = "1.27.1-rc.2"
|
||||
let version = "1.27.3"
|
||||
// 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.1-rc.2"
|
||||
let checksum = "bad8b1adf12f0d1ab7ad093ca74727d6fafc2a3b2066e67e92bec3938ef0e0c1"
|
||||
let tag = "1.27.3"
|
||||
let checksum = "f0c6b4e6ffc6269a67b0d4ff254e3e8acfc6b3852db7b9957d4c0a5b39044446"
|
||||
let url = "https://github.com/sparkle-project/Sparkle/releases/download/\(tag)/Sparkle-for-Swift-Package-Manager.zip"
|
||||
|
||||
let package = Package(
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Sparkle"
|
||||
s.version = "1.27.1-rc.2"
|
||||
s.version = "1.27.3"
|
||||
s.summary = "A software update framework for macOS"
|
||||
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
|
||||
s.homepage = "https://sparkle-project.org"
|
||||
|
||||
Vendored
+27
-14
@@ -30,6 +30,7 @@
|
||||
|
||||
#import "SPUURLRequest.h"
|
||||
#import "SPUDownloaderSession.h"
|
||||
#import "SPULocalCacheDirectory.h"
|
||||
|
||||
@interface SUBasicUpdateDriver ()
|
||||
|
||||
@@ -38,6 +39,7 @@
|
||||
@property (assign) NSComparisonResult latestAppcastItemComparisonResult;
|
||||
@property (strong) SPUDownloader *download;
|
||||
@property (copy) NSString *downloadPath;
|
||||
@property (copy) NSString *extractionDirectory;
|
||||
|
||||
@property (strong) SUAppcastItem *nonDeltaUpdateItem;
|
||||
@property (copy) NSString *tempDir;
|
||||
@@ -54,6 +56,7 @@
|
||||
@synthesize latestAppcastItemComparisonResult;
|
||||
@synthesize download;
|
||||
@synthesize downloadPath;
|
||||
@synthesize extractionDirectory = _extractionDirectory;
|
||||
|
||||
@synthesize nonDeltaUpdateItem;
|
||||
@synthesize tempDir;
|
||||
@@ -383,6 +386,7 @@
|
||||
{
|
||||
self.tempDir = temporaryDirectory;
|
||||
self.downloadPath = [temporaryDirectory stringByAppendingPathComponent:destinationName];
|
||||
self.extractionDirectory = [SPULocalCacheDirectory createUniqueDirectoryInDirectory:temporaryDirectory];
|
||||
}
|
||||
|
||||
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)__unused expectedContentLength
|
||||
@@ -441,22 +445,30 @@
|
||||
|
||||
- (void)extractUpdate
|
||||
{
|
||||
id<SUUpdaterPrivate> updater = self.updater;
|
||||
id<SUUnarchiverProtocol> unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:self.host.bundlePath decryptionPassword:updater.decryptionPassword];
|
||||
|
||||
BOOL success = NO;
|
||||
if (!unarchiver) {
|
||||
SULog(SULogLevelError, @"Error: No valid unarchiver for %@!", self.downloadPath);
|
||||
|
||||
id<SUUpdaterPrivate> updater = self.updater;
|
||||
|
||||
id<SUUnarchiverProtocol> unarchiver;
|
||||
if (self.extractionDirectory == nil) {
|
||||
SULog(SULogLevelError, @"Error: Failed to create temporary extraction directory for %@!", self.downloadPath);
|
||||
unarchiver = nil;
|
||||
} else {
|
||||
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath signatures:self.updateItem.signatures host:self.host];
|
||||
|
||||
// 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];
|
||||
unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath extractionDirectory:self.extractionDirectory updatingHostBundlePath:self.host.bundlePath decryptionPassword:updater.decryptionPassword];
|
||||
|
||||
if (!unarchiver) {
|
||||
SULog(SULogLevelError, @"Error: No valid unarchiver for %@!", self.downloadPath);
|
||||
} else {
|
||||
success = YES;
|
||||
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath signatures:self.updateItem.signatures host:self.host];
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,8 +572,9 @@
|
||||
{
|
||||
assert(self.updateItem);
|
||||
assert(self.updateValidator);
|
||||
assert(self.extractionDirectory);
|
||||
|
||||
BOOL validationCheckSuccess = [self.updateValidator validateWithUpdateDirectory:self.tempDir];
|
||||
BOOL validationCheckSuccess = [self.updateValidator validateWithUpdateDirectory:self.extractionDirectory];
|
||||
if (!validationCheckSuccess) {
|
||||
NSDictionary *userInfo = @{
|
||||
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
|
||||
|
||||
Vendored
+1
-1
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUBinaryDeltaUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath updateHostBundlePath:(NSString *)updateHostBundlePath;
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath extractionDirectory:(NSString *)extractionDirectory updateHostBundlePath:(NSString *)updateHostBundlePath;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+5
-2
@@ -20,6 +20,7 @@
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *archivePath;
|
||||
@property (nonatomic, copy, readonly) NSString *updateHostBundlePath;
|
||||
@property (nonatomic, copy, readonly) NSString *extractionDirectory;
|
||||
|
||||
@end
|
||||
|
||||
@@ -27,6 +28,7 @@
|
||||
|
||||
@synthesize archivePath = _archivePath;
|
||||
@synthesize updateHostBundlePath = _updateHostBundlePath;
|
||||
@synthesize extractionDirectory = _extractionDirectory;
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
@@ -73,12 +75,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath updateHostBundlePath:(NSString *)updateHostBundlePath
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath extractionDirectory:(NSString *)extractionDirectory updateHostBundlePath:(NSString *)updateHostBundlePath
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_archivePath = [archivePath copy];
|
||||
_updateHostBundlePath = [updateHostBundlePath copy];
|
||||
_extractionDirectory = [extractionDirectory copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -96,7 +99,7 @@
|
||||
- (void)extractDeltaWithNotifier:(SUUnarchiverNotifier *)notifier
|
||||
{
|
||||
NSString *sourcePath = self.updateHostBundlePath;
|
||||
NSString *targetPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
||||
NSString *targetPath = [self.extractionDirectory stringByAppendingPathComponent:[sourcePath lastPathComponent]];
|
||||
|
||||
NSError *applyDiffError = nil;
|
||||
BOOL success = applyBinaryDelta(sourcePath, targetPath, self.archivePath, NO, ^(double progress){
|
||||
|
||||
Vendored
-1
@@ -18,7 +18,6 @@
|
||||
|
||||
extern const NSTimeInterval SUMinimumUpdateCheckInterval;
|
||||
extern const NSTimeInterval SUDefaultUpdateCheckInterval;
|
||||
extern const NSTimeInterval SUMinimumMonotonicUpdateCheckInterval;
|
||||
|
||||
extern NSString *const SUBundleIdentifier;
|
||||
|
||||
|
||||
Vendored
-1
@@ -18,7 +18,6 @@
|
||||
// Define some minimum intervals to avoid DoS-like checking attacks
|
||||
const NSTimeInterval SUMinimumUpdateCheckInterval = DEBUG ? 60 : (60 * 60);
|
||||
const NSTimeInterval SUDefaultUpdateCheckInterval = DEBUG ? 60 : (60 * 60 * 24);
|
||||
const NSTimeInterval SUMinimumMonotonicUpdateCheckInterval = DEBUG ? 30 : (60 * 5);
|
||||
|
||||
NSString *const SUBundleIdentifier = @SPARKLE_BUNDLE_IDENTIFIER;
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUDiskImageUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath extractionDirectory:(NSString *)extractionDirectory decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+5
-2
@@ -17,6 +17,7 @@
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *archivePath;
|
||||
@property (nullable, nonatomic, copy, readonly) NSString *decryptionPassword;
|
||||
@property (nonatomic, copy, readonly) NSString *extractionDirectory;
|
||||
|
||||
@end
|
||||
|
||||
@@ -24,6 +25,7 @@
|
||||
|
||||
@synthesize archivePath = _archivePath;
|
||||
@synthesize decryptionPassword = _decryptionPassword;
|
||||
@synthesize extractionDirectory = _extractionDirectory;
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
@@ -35,12 +37,13 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath decryptionPassword:(nullable NSString *)decryptionPassword
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath extractionDirectory:(NSString *)extractionDirectory decryptionPassword:(nullable NSString *)decryptionPassword
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_archivePath = [archivePath copy];
|
||||
_decryptionPassword = [decryptionPassword copy];
|
||||
_extractionDirectory = [extractionDirectory copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -158,7 +161,7 @@
|
||||
for (NSString *item in contents)
|
||||
{
|
||||
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
|
||||
NSString *toPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
||||
NSString *toPath = [self.extractionDirectory stringByAppendingPathComponent:item];
|
||||
|
||||
// We skip any files in the DMG which are not readable.
|
||||
if (![manager isReadableFileAtPath:fromPath]) {
|
||||
|
||||
Vendored
+1
-1
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// An unarchiver for flat packages that doesn't really do any unarchiving
|
||||
@interface SUFlatPackageUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
|
||||
- (instancetype)initWithFlatPackagePath:(NSString *)flatPackagePath;
|
||||
- (instancetype)initWithFlatPackagePath:(NSString *)flatPackagePath extractionDirectory:(NSString *)extractionDirectory;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+18
-3
@@ -16,12 +16,14 @@
|
||||
@interface SUFlatPackageUnarchiver ()
|
||||
|
||||
@property (nonatomic, readonly) NSString *flatPackagePath;
|
||||
@property (nonatomic, readonly, copy) NSString *extractionDirectory;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUFlatPackageUnarchiver
|
||||
|
||||
@synthesize flatPackagePath = _flatPackagePath;
|
||||
@synthesize extractionDirectory = _extractionDirectory;
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
@@ -34,11 +36,12 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFlatPackagePath:(NSString *)flatPackagePath;
|
||||
- (instancetype)initWithFlatPackagePath:(NSString *)flatPackagePath extractionDirectory:(NSString *)extractionDirectory
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_flatPackagePath = [flatPackagePath copy];
|
||||
_extractionDirectory = [extractionDirectory copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -54,8 +57,20 @@
|
||||
} 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]}]];
|
||||
} else {
|
||||
[notifier notifyProgress:1.0];
|
||||
[notifier notifySuccess];
|
||||
// Copying the flat package should be very fast, especially on APFS
|
||||
NSError *copyError = nil;
|
||||
if (![[NSFileManager defaultManager] copyItemAtPath:self.flatPackagePath toPath:[self.extractionDirectory stringByAppendingPathComponent:self.flatPackagePath.lastPathComponent] error:©Error]) {
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+28
-13
@@ -20,15 +20,6 @@
|
||||
|
||||
@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
|
||||
{
|
||||
NSParameterAssert(inUpdateFolder);
|
||||
@@ -47,6 +38,34 @@
|
||||
|
||||
while ((currentFile = [dirEnum nextObject])) {
|
||||
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 *currentExtension = [currentFile pathExtension];
|
||||
NSString *currentFilenameNoExtension = [currentFilename stringByDeletingPathExtension];
|
||||
@@ -76,10 +95,6 @@
|
||||
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.
|
||||
|
||||
Vendored
+1
-1
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUPipedUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath;
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath extractionDirectory:(NSString *)extractionDirectory;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+5
-2
@@ -17,12 +17,14 @@
|
||||
@interface SUPipedUnarchiver ()
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *archivePath;
|
||||
@property (nonatomic, copy, readonly) NSString *extractionDirectory;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUPipedUnarchiver
|
||||
|
||||
@synthesize archivePath = _archivePath;
|
||||
@synthesize extractionDirectory = _extractionDirectory;
|
||||
|
||||
+ (nullable NSArray <NSString *> *)commandAndArgumentsConformingToTypeOfPath:(NSString *)path
|
||||
{
|
||||
@@ -63,11 +65,12 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath
|
||||
- (instancetype)initWithArchivePath:(NSString *)archivePath extractionDirectory:(NSString *)extractionDirectory
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_archivePath = [archivePath copy];
|
||||
_extractionDirectory = [extractionDirectory copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -94,7 +97,7 @@
|
||||
// *** GETS CALLED ON NON-MAIN THREAD!!!
|
||||
@autoreleasepool {
|
||||
NSError *error = nil;
|
||||
NSString *destination = [self.archivePath stringByDeletingLastPathComponent];
|
||||
NSString *destination = self.extractionDirectory;
|
||||
|
||||
SULog(SULogLevelDefault, @"Extracting using '%@' '%@' < '%@' '%@'", command, [args componentsJoinedByString:@"' '"], self.archivePath, destination);
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUUnarchiver : NSObject
|
||||
|
||||
+ (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
+ (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path extractionDirectory:(NSString *)extractionDirectory updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+5
-6
@@ -18,21 +18,20 @@
|
||||
|
||||
@implementation SUUnarchiver
|
||||
|
||||
+ (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword
|
||||
+ (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path extractionDirectory:(NSString *)extractionDirectory updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword
|
||||
{
|
||||
if ([SUPipedUnarchiver canUnarchivePath:path]) {
|
||||
return [[SUPipedUnarchiver alloc] initWithArchivePath:path];
|
||||
|
||||
return [[SUPipedUnarchiver alloc] initWithArchivePath:path extractionDirectory:extractionDirectory];
|
||||
} else if ([SUDiskImageUnarchiver canUnarchivePath:path]) {
|
||||
return [[SUDiskImageUnarchiver alloc] initWithArchivePath:path decryptionPassword:decryptionPassword];
|
||||
return [[SUDiskImageUnarchiver alloc] initWithArchivePath:path extractionDirectory:extractionDirectory decryptionPassword:decryptionPassword];
|
||||
|
||||
} else if ([SUBinaryDeltaUnarchiver canUnarchivePath:path]) {
|
||||
assert(hostPath != nil);
|
||||
NSString *nonNullHostPath = hostPath;
|
||||
return [[SUBinaryDeltaUnarchiver alloc] initWithArchivePath:path updateHostBundlePath:nonNullHostPath];
|
||||
return [[SUBinaryDeltaUnarchiver alloc] initWithArchivePath:path extractionDirectory:extractionDirectory updateHostBundlePath:nonNullHostPath];
|
||||
|
||||
} else if ([SUFlatPackageUnarchiver canUnarchivePath:path]) {
|
||||
return [[SUFlatPackageUnarchiver alloc] initWithFlatPackagePath:path];
|
||||
return [[SUFlatPackageUnarchiver alloc] initWithFlatPackagePath:path extractionDirectory:extractionDirectory];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
Vendored
+14
-68
@@ -41,7 +41,6 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
@property (assign) BOOL shouldRescheduleOnWake;
|
||||
@property (strong) NSBundle *sparkleBundle;
|
||||
@property (nonatomic) BOOL loggedNoSecureKeyWarning;
|
||||
@property (nonatomic) NSTimeInterval lastMonotonicUpdateCheckTime;
|
||||
|
||||
- (instancetype)initForBundle:(NSBundle *)bundle;
|
||||
- (void)startUpdateCycle;
|
||||
@@ -72,7 +71,6 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
@synthesize decryptionPassword;
|
||||
@synthesize updateLastCheckedDate;
|
||||
@synthesize loggedNoSecureKeyWarning = _loggedNoSecureKeyWarning;
|
||||
@synthesize lastMonotonicUpdateCheckTime = _lastMonotonicUpdateCheckTime;
|
||||
|
||||
static NSMutableDictionary *sharedUpdaters = nil;
|
||||
static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObservationContext";
|
||||
@@ -287,21 +285,11 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
return [self updateLastCheckedDate];
|
||||
}
|
||||
|
||||
- (NSTimeInterval)currentMonotonicTimeInterval
|
||||
{
|
||||
// This is monotonic system time while the system is not asleep
|
||||
return [[NSProcessInfo processInfo] systemUptime];
|
||||
}
|
||||
|
||||
- (void)updateLastUpdateCheckDate
|
||||
{
|
||||
[self willChangeValueForKey:@"lastUpdateCheckDate"];
|
||||
|
||||
[self setUpdateLastCheckedDate:[NSDate date]];
|
||||
[self.host setObject:[self updateLastCheckedDate] forUserDefaultsKey:SULastCheckTimeKey];
|
||||
|
||||
self.lastMonotonicUpdateCheckTime = [self currentMonotonicTimeInterval];
|
||||
|
||||
[self didChangeValueForKey:@"lastUpdateCheckDate"];
|
||||
}
|
||||
|
||||
@@ -315,70 +303,30 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
if (![self automaticallyChecksForUpdates]) return;
|
||||
|
||||
// How long has it been since last we checked for an update?
|
||||
NSTimeInterval dateIntervalSinceCheck;
|
||||
NSTimeInterval minimumEnforcedDelay;
|
||||
NSTimeInterval intervalSinceCheck;
|
||||
if (usingCurrentDate) {
|
||||
NSDate *lastCheckDate = [self lastUpdateCheckDate];
|
||||
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
|
||||
NSTimeInterval wallTimeInterval = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
|
||||
if (wallTimeInterval < 0) {
|
||||
intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
|
||||
if (intervalSinceCheck < 0) {
|
||||
// Last update check date is in the future and bogus, so reset it to current date
|
||||
[self updateLastUpdateCheckDate];
|
||||
|
||||
// And assume a full update interval is needed
|
||||
dateIntervalSinceCheck = 0;
|
||||
minimumEnforcedDelay = SUMinimumMonotonicUpdateCheckInterval;
|
||||
} else {
|
||||
// Check the monotonic clock for an enforced minimum delay
|
||||
NSTimeInterval lastMonotonicUpdateCheckTime = self.lastMonotonicUpdateCheckTime;
|
||||
if (lastMonotonicUpdateCheckTime <= 0) {
|
||||
// When the updater is first started, the last monotonic time may not have been updated yet.
|
||||
// In this case there is no enforced minimum delay.
|
||||
minimumEnforcedDelay = 0;
|
||||
} else {
|
||||
// Compute an enforced minimum delay based on elapsed monotonic time
|
||||
// The elapsed monotonic time is more stable than wall time interval and does not include the
|
||||
// amount of time while the system is asleep
|
||||
NSTimeInterval currentMonotonicTime = [self currentMonotonicTimeInterval];
|
||||
NSTimeInterval elapsedMonotonicTime = (currentMonotonicTime - lastMonotonicUpdateCheckTime);
|
||||
|
||||
if (elapsedMonotonicTime < SUMinimumMonotonicUpdateCheckInterval) {
|
||||
minimumEnforcedDelay = (SUMinimumMonotonicUpdateCheckInterval - elapsedMonotonicTime);
|
||||
} else {
|
||||
minimumEnforcedDelay = 0;
|
||||
}
|
||||
}
|
||||
|
||||
dateIntervalSinceCheck = wallTimeInterval;
|
||||
intervalSinceCheck = 0;
|
||||
}
|
||||
} else {
|
||||
// Without using the current date, we assume a full update interval is needed
|
||||
dateIntervalSinceCheck = 0;
|
||||
minimumEnforcedDelay = SUMinimumMonotonicUpdateCheckInterval;
|
||||
intervalSinceCheck = 0;
|
||||
}
|
||||
|
||||
NSTimeInterval updateCheckInterval = [self updateCheckInterval];
|
||||
if (updateCheckInterval < SUMinimumUpdateCheckInterval) {
|
||||
updateCheckInterval = SUMinimumUpdateCheckInterval;
|
||||
}
|
||||
|
||||
// Now we want to figure out how long until we check again.
|
||||
NSTimeInterval delayUntilCheck;
|
||||
if (dateIntervalSinceCheck < updateCheckInterval) {
|
||||
// It hasn't been long enough.
|
||||
delayUntilCheck = (updateCheckInterval - dateIntervalSinceCheck);
|
||||
} else {
|
||||
// We're overdue!
|
||||
delayUntilCheck = 0;
|
||||
}
|
||||
|
||||
// Now compute delay with enforced minimum delay requirement
|
||||
// The minimum delay (based on monotonic clock) is an extra layer of defense to prevent too frequent update checks
|
||||
// in case the wall clock is not working properly (eg from too many system wake events, system date changes, NTP..)
|
||||
NSTimeInterval delayUntilCheckWithMinimumEnforcedDelay =
|
||||
(delayUntilCheck < minimumEnforcedDelay) ? minimumEnforcedDelay : delayUntilCheck;
|
||||
|
||||
self.checkTimer = [NSTimer scheduledTimerWithTimeInterval:delayUntilCheckWithMinimumEnforcedDelay target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO];
|
||||
NSTimeInterval delayUntilCheck, updateCheckInterval = [self updateCheckInterval];
|
||||
if (updateCheckInterval < SUMinimumUpdateCheckInterval)
|
||||
updateCheckInterval = SUMinimumUpdateCheckInterval;
|
||||
if (intervalSinceCheck < updateCheckInterval)
|
||||
delayUntilCheck = (updateCheckInterval - intervalSinceCheck); // It hasn't been long enough.
|
||||
else
|
||||
delayUntilCheck = 0; // We're overdue! Run one now.
|
||||
self.checkTimer = [NSTimer scheduledTimerWithTimeInterval:delayUntilCheck target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO]; // Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
}
|
||||
|
||||
- (void)receiveSleepNote
|
||||
@@ -395,10 +343,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
|
||||
- (void)receiveWakeNote
|
||||
{
|
||||
// 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) {
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesInBackground
|
||||
|
||||
@@ -24,10 +24,9 @@ class SUUnarchiverTest: XCTestCase
|
||||
let unarchivedSuccessExpectation = super.expectation(description: "Unarchived Success (format: \(archiveExtension))")
|
||||
let unarchivedFailureExpectation = super.expectation(description: "Unarchived Failure (format: \(archiveExtension))")
|
||||
|
||||
let tempArchiveURL = tempDirectoryURL.appendingPathComponent(archiveResourceURL.lastPathComponent)
|
||||
let extractedAppURL = tempDirectoryURL.appendingPathComponent(appName).appendingPathExtension("app")
|
||||
|
||||
self.unarchiveTestAppWithExtension(archiveExtension, appName: appName, tempDirectoryURL: tempDirectoryURL, tempArchiveURL: tempArchiveURL, archiveResourceURL: archiveResourceURL, password: password, expectingSuccess: expectingSuccess, testExpectation: unarchivedSuccessExpectation)
|
||||
self.unarchiveTestAppWithExtension(archiveExtension, appName: appName, tempDirectoryURL: tempDirectoryURL, archiveResourceURL: archiveResourceURL, password: password, expectingSuccess: expectingSuccess, testExpectation: unarchivedSuccessExpectation)
|
||||
self.unarchiveNonExistentFileTestFailureAppWithExtension(archiveExtension, tempDirectoryURL: tempDirectoryURL, password: password, testExpectation: unarchivedFailureExpectation)
|
||||
|
||||
super.waitForExpectations(timeout: 30.0, handler: nil)
|
||||
@@ -40,7 +39,7 @@ class SUUnarchiverTest: XCTestCase
|
||||
|
||||
func unarchiveNonExistentFileTestFailureAppWithExtension(_ archiveExtension: String, tempDirectoryURL: URL, password: String?, testExpectation: XCTestExpectation) {
|
||||
let tempArchiveURL = tempDirectoryURL.appendingPathComponent("error-invalid").appendingPathExtension(archiveExtension)
|
||||
let unarchiver = SUUnarchiver.unarchiver(forPath: tempArchiveURL.path, updatingHostBundlePath: nil, decryptionPassword: password)!
|
||||
let unarchiver = SUUnarchiver.unarchiver(forPath: tempArchiveURL.path, extractionDirectory: tempDirectoryURL.path, updatingHostBundlePath: nil, decryptionPassword: password)!
|
||||
|
||||
unarchiver.unarchive(completionBlock: {(error: Error?) -> Void in
|
||||
XCTAssertNotNil(error)
|
||||
@@ -49,13 +48,8 @@ class SUUnarchiverTest: XCTestCase
|
||||
}
|
||||
|
||||
// swiftlint:disable function_parameter_count
|
||||
func unarchiveTestAppWithExtension(_ archiveExtension: String, appName: String, tempDirectoryURL: URL, tempArchiveURL: URL, archiveResourceURL: URL, password: String?, expectingSuccess: Bool, testExpectation: XCTestExpectation) {
|
||||
|
||||
let fileManager = FileManager.default
|
||||
|
||||
try! fileManager.copyItem(at: archiveResourceURL, to: tempArchiveURL)
|
||||
|
||||
let unarchiver = SUUnarchiver.unarchiver(forPath: tempArchiveURL.path, updatingHostBundlePath: nil, decryptionPassword: password)!
|
||||
func unarchiveTestAppWithExtension(_ archiveExtension: String, appName: String, tempDirectoryURL: URL, archiveResourceURL: URL, password: String?, expectingSuccess: Bool, testExpectation: XCTestExpectation) {
|
||||
let unarchiver = SUUnarchiver.unarchiver(forPath: archiveResourceURL.path, extractionDirectory: tempDirectoryURL.path, updatingHostBundlePath: nil, decryptionPassword: password)!
|
||||
|
||||
unarchiver.unarchive(completionBlock: {(error: Error?) -> Void in
|
||||
if expectingSuccess {
|
||||
|
||||
@@ -8,38 +8,26 @@ import Foundation
|
||||
func unarchive(itemPath: URL, archiveDestDir: URL, callback: @escaping (Error?) -> Void) {
|
||||
let fileManager = FileManager.default
|
||||
let tempDir = archiveDestDir.appendingPathExtension("tmp")
|
||||
let itemCopy = tempDir.appendingPathComponent(itemPath.lastPathComponent)
|
||||
|
||||
_ = try? fileManager.removeItem(at: tempDir)
|
||||
_ = try? fileManager.createDirectory(at: tempDir, withIntermediateDirectories: true, attributes: [:])
|
||||
|
||||
do {
|
||||
do {
|
||||
try fileManager.linkItem(at: itemPath, to: itemCopy)
|
||||
} catch {
|
||||
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
|
||||
}
|
||||
if let unarchiver = SUUnarchiver.unarchiver(forPath: itemPath.path, extractionDirectory: tempDir.path, updatingHostBundlePath: nil, decryptionPassword: nil) {
|
||||
unarchiver.unarchive(completionBlock: { (error: Error?) in
|
||||
if error != nil {
|
||||
callback(error)
|
||||
return
|
||||
}
|
||||
|
||||
_ = try? fileManager.removeItem(at: itemCopy)
|
||||
do {
|
||||
try fileManager.moveItem(at: tempDir, to: archiveDestDir)
|
||||
callback(nil)
|
||||
} catch {
|
||||
callback(error)
|
||||
}
|
||||
}, progressBlock: nil)
|
||||
} else {
|
||||
_ = try? fileManager.removeItem(at: itemCopy)
|
||||
callback(makeError(code: .unarchivingError, "Not a supported archive format: \(itemCopy)"))
|
||||
}
|
||||
} catch {
|
||||
_ = try? fileManager.removeItem(at: tempDir)
|
||||
callback(error)
|
||||
do {
|
||||
try fileManager.moveItem(at: tempDir, to: archiveDestDir)
|
||||
callback(nil)
|
||||
} catch {
|
||||
callback(error)
|
||||
}
|
||||
}, progressBlock: nil)
|
||||
} else {
|
||||
callback(makeError(code: .unarchivingError, "Not a supported archive format: \(itemPath.path)"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user