mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-30 05:28:50 +00:00
Fix minor binary delta issues and make version 3 the default (#2055)
This commit is contained in:
8 files changed
+25
-23
No files matched your search
@@ -85,7 +85,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
CLONE_FILE and EXTRACT_FILE cannot be combined.
|
||||
MODIFY_PERMISSIONS can be combined with either CLONE_FILE, EXTRACT_FILE, BINARY_DIFF_FILE, or just by itself.
|
||||
CLONE_FILE can be combined with BINARY_DIFF_FILE or just by itself.
|
||||
DELETE can be combined with EXTRACT_FILE, BINARY_DIFF_FILE, or just by itself. (we don't currently combine it with BINARY_DIFF_FILE however)
|
||||
DELETE can be combined with EXTRACT_FILE, or just by itself. It is only combined with EXTRACT_FILE when the file type (regular, directory, or symlink) changes.
|
||||
|
||||
[ DATA_BLOBS ]
|
||||
All raw binary data joined together
|
||||
|
||||
@@ -623,6 +623,8 @@ static compression_algorithm _compressionAlgorithmForMode(SPUDeltaCompressionMod
|
||||
return NO;
|
||||
}
|
||||
|
||||
[fileManager removeItemAtPath:itemFilePath error:NULL];
|
||||
|
||||
NSError *createLinkError = nil;
|
||||
if (![fileManager createSymbolicLinkAtPath:itemFilePath withDestinationPath:destinationPath error:&createLinkError]) {
|
||||
self.error = createLinkError;
|
||||
|
||||
@@ -219,6 +219,9 @@ BOOL applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
|
||||
NSString *clonedOriginalPath = [source stringByAppendingPathComponent:clonedRelativePath];
|
||||
|
||||
// Ensure there isn't an item already at our destination
|
||||
[fileManager removeItemAtPath:destinationFilePath error:NULL];
|
||||
|
||||
NSError *copyError = nil;
|
||||
if (![fileManager copyItemAtPath:clonedOriginalPath toPath:destinationFilePath error:©Error]) {
|
||||
if (verbose) {
|
||||
|
||||
@@ -45,7 +45,7 @@ extern SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionLatest;
|
||||
extern SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionFirst;
|
||||
extern SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionFirstSupported;
|
||||
|
||||
#define COMPRESSION_METHOD_ARGUMENT_DESCRIPTION @"The compression method to use for generating delta updates. Supported methods for version 3 delta files are 'lzma', 'bzip2', 'zlib', 'lzfse', 'lz4', 'none', and 'default'. Note that version 2 delta files only support 'bzip2', 'none', and 'default' so other methods will be ignored if version 2 files are being generated."
|
||||
#define COMPRESSION_METHOD_ARGUMENT_DESCRIPTION @"The compression method to use for generating delta updates. Supported methods for version 3 delta files are 'lzma', 'bzip2', 'zlib', 'lzfse', 'lz4', 'none', and 'default'. Note that version 2 delta files only support 'bzip2', 'none', and 'default' so other methods will be ignored if version 2 files are being generated. The 'default' compression for version 3 delta files is currently lzma."
|
||||
|
||||
#define COMPRESSION_LEVEL_ARGUMENT_DESCRIPTION @"The compression level to use for generating delta updates. This only applies if the compression method used is bzip2 which accepts values from 1 - 9. A special value of 0 will use the default compression level."
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
// Note: the framework bundle version must be bumped, and generate_appcast must be updated to compare it,
|
||||
// when we add/change new major versions and defaults. Unit tests need to be updated to use new versions too.
|
||||
SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionDefault = SUBinaryDeltaMajorVersion2;
|
||||
SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionDefault = SUBinaryDeltaMajorVersion3;
|
||||
SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionLatest = SUBinaryDeltaMajorVersion3;
|
||||
SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionFirst = SUBinaryDeltaMajorVersion1;
|
||||
SUBinaryDeltaMajorVersion SUBinaryDeltaMajorVersionFirstSupported = SUBinaryDeltaMajorVersion2;
|
||||
|
||||
@@ -195,7 +195,7 @@ static BOOL shouldSkipDeltaCompression(NSDictionary *originalInfo, NSDictionary
|
||||
return NO;
|
||||
}
|
||||
|
||||
static BOOL shouldDeleteThenExtract(NSDictionary *originalInfo, NSDictionary *newInfo, SUBinaryDeltaMajorVersion majorVersion)
|
||||
static BOOL shouldDeleteThenExtract(NSDictionary *originalInfo, NSDictionary *newInfo)
|
||||
{
|
||||
if (!originalInfo) {
|
||||
return NO;
|
||||
@@ -204,14 +204,6 @@ static BOOL shouldDeleteThenExtract(NSDictionary *originalInfo, NSDictionary *ne
|
||||
if ([(NSNumber *)originalInfo[INFO_TYPE_KEY] unsignedShortValue] != [(NSNumber *)newInfo[INFO_TYPE_KEY] unsignedShortValue]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// If the same file exists in both old and new trees and they have different content,
|
||||
// we should always issue deleting the old file before extracting the new
|
||||
// I believe xar container in version 2 format automatically did this if the file types were the same
|
||||
// but we don't want to rely on that implicitness
|
||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBinaryDeltaMajorVersion3)) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
@@ -470,6 +462,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
}
|
||||
fts_close(fts);
|
||||
|
||||
// This dictionary will help us keep track of clones
|
||||
NSMutableDictionary<NSData *, NSMutableArray<NSString *> *> *beforeHashToFileKeyDictionary = MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBinaryDeltaMajorVersion3) ? [NSMutableDictionary dictionary] : nil;
|
||||
|
||||
unsigned char beforeHash[CC_SHA1_DIGEST_LENGTH] = {0};
|
||||
@@ -559,7 +552,16 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
|
||||
NSDictionary *oldInfo = originalTreeState[key];
|
||||
|
||||
if ([info isEqual:oldInfo]) {
|
||||
BOOL hasEqualInfo;
|
||||
if (![info isEqual:oldInfo]) {
|
||||
hasEqualInfo = NO;
|
||||
} else {
|
||||
NSString *originalPath = oldInfo[INFO_PATH_KEY];
|
||||
NSString *newPath = info[INFO_PATH_KEY];
|
||||
hasEqualInfo = [[NSFileManager defaultManager] contentsEqualAtPath:originalPath andPath:newPath];
|
||||
}
|
||||
|
||||
if (hasEqualInfo) {
|
||||
[newTreeState removeObjectForKey:key];
|
||||
} else {
|
||||
newTreeState[key] = info;
|
||||
@@ -579,6 +581,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
}
|
||||
fts_close(fts);
|
||||
|
||||
// This dictionary will help us keep track of clones
|
||||
NSMutableDictionary<NSString *, NSData *> *afterFileKeyToHashDictionary = MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBinaryDeltaMajorVersion3) ? [NSMutableDictionary dictionary] : nil;
|
||||
|
||||
unsigned char afterHash[CC_SHA1_DIGEST_LENGTH] = {0};
|
||||
@@ -766,9 +769,6 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
[deltaOperations addObject:operation];
|
||||
} else {
|
||||
SPUDeltaItemCommands commands = SPUDeltaItemCommandClone;
|
||||
if (shouldDeleteThenExtract(originalInfo, newInfo, majorVersion)) {
|
||||
commands |= SPUDeltaItemCommandDelete;
|
||||
}
|
||||
if (clonePermissionsChanged) {
|
||||
commands |= SPUDeltaItemCommandModifyPermissions;
|
||||
}
|
||||
@@ -790,7 +790,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
NSString *path = [destination stringByAppendingPathComponent:key];
|
||||
|
||||
SPUDeltaItemCommands commands = SPUDeltaItemCommandExtract;
|
||||
if (shouldDeleteThenExtract(originalInfo, newInfo, majorVersion)) {
|
||||
if (shouldDeleteThenExtract(originalInfo, newInfo)) {
|
||||
commands |= SPUDeltaItemCommandDelete;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ SPARKLE_VERSION_PATCH = 0
|
||||
// This should be in SemVer format or empty, ie. "-beta.1"
|
||||
// These variables must have a space after the '=' too
|
||||
SPARKLE_VERSION_SUFFIX =
|
||||
CURRENT_PROJECT_VERSION = 2009
|
||||
CURRENT_PROJECT_VERSION = 2010
|
||||
|
||||
MARKETING_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)$(SPARKLE_VERSION_SUFFIX)
|
||||
ALWAYS_SEARCH_USER_PATHS = NO
|
||||
|
||||
@@ -111,11 +111,8 @@ func makeAppcast(archivesSourceDir: URL, cacheDirectory cacheDir: URL, keys: Pri
|
||||
do {
|
||||
// Decide the most appropriate delta version
|
||||
let deltaVersion: SUBinaryDeltaMajorVersion
|
||||
if SUBinaryDeltaMajorVersionDefault == .version2 {
|
||||
// Remove this branch when we change the default delta version to .version3
|
||||
deltaVersion = .version2
|
||||
} else if let frameworkVersion = item.frameworkVersion {
|
||||
switch comparator.compareVersion(frameworkVersion, toVersion: "2009") {
|
||||
if let frameworkVersion = item.frameworkVersion {
|
||||
switch comparator.compareVersion(frameworkVersion, toVersion: "2010") {
|
||||
case .orderedSame:
|
||||
fallthrough
|
||||
case .orderedDescending:
|
||||
|
||||
Reference in new issue
Block a user