mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Add an extract property for creating/applying binary diffs
Before, an extract was assumed if nothing else matched. This can get quite confusing when adding new properties, so we shouldn't treat any property to be handled if nothing else was handled.
This commit is contained in:
1 parent
cd478a4c48
commit
9e9fef0d51
3 files changed
+19
-6
No files matched your search
Vendored
+8
-4
@@ -120,6 +120,8 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
||||
fprintf(stderr, "Failed to copy %s to %s\n", [source fileSystemRepresentation], [destination fileSystemRepresentation]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL hasExtractKeyAvailable = MAJOR_VERSION_IS_AT_LEAST(majorDiffVersion, SUBeigeMajorVersion);
|
||||
|
||||
fprintf(stdout, "\nPatching... ");
|
||||
xar_file_t file;
|
||||
@@ -130,12 +132,13 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
||||
NSString *destinationFilePath = [destination stringByAppendingPathComponent:path];
|
||||
|
||||
const char *value;
|
||||
if (!xar_prop_get(file, DELETE_KEY, &value) || !xar_prop_get(file, DELETE_THEN_EXTRACT_KEY, &value)) {
|
||||
if (!xar_prop_get(file, DELETE_KEY, &value) ||
|
||||
(!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_THEN_EXTRACT_OLD_KEY, &value))) {
|
||||
if (!removeTree(destinationFilePath)) {
|
||||
fprintf(stderr, "%s or %s: failed to remove %s\n", DELETE_KEY, DELETE_THEN_EXTRACT_KEY, [destination fileSystemRepresentation]);
|
||||
fprintf(stderr, "%s or %s: failed to remove %s\n", DELETE_KEY, DELETE_THEN_EXTRACT_OLD_KEY, [destination fileSystemRepresentation]);
|
||||
return 1;
|
||||
}
|
||||
if (!xar_prop_get(file, DELETE_KEY, &value))
|
||||
if (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_KEY, &value))
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -144,7 +147,8 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
|
||||
fprintf(stderr, "Unable to patch %s to destination %s\n", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation]);
|
||||
return 1;
|
||||
}
|
||||
} else if (xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value)) {
|
||||
} else if ((hasExtractKeyAvailable && !xar_prop_get(file, EXTRACT_KEY, &value)) ||
|
||||
(!hasExtractKeyAvailable && xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value))) { // extract and permission modifications don't coexist
|
||||
if (xar_extract_tofile(x, file, [destinationFilePath fileSystemRepresentation]) != 0) {
|
||||
fprintf(stderr, "Unable to extract file to %s\n", [destinationFilePath fileSystemRepresentation]);
|
||||
return 1;
|
||||
|
||||
Vendored
+2
-1
@@ -22,11 +22,12 @@
|
||||
#define BEFORE_TREE_SHA1_KEY "before-tree-sha1"
|
||||
#define AFTER_TREE_SHA1_KEY "after-tree-sha1"
|
||||
#define DELETE_KEY "delete"
|
||||
#define DELETE_THEN_EXTRACT_KEY "delete-then-extract"
|
||||
#define EXTRACT_KEY "extract"
|
||||
#define BINARY_DELTA_KEY "binary-delta"
|
||||
#define MODIFY_PERMISSIONS_KEY "mod-permissions"
|
||||
|
||||
// Properties no longer used in new patches
|
||||
#define DELETE_THEN_EXTRACT_OLD_KEY "delete-then-extract"
|
||||
#define BEFORE_TREE_SHA1_OLD_KEY "before-sha1"
|
||||
#define AFTER_TREE_SHA1_OLD_KEY "after-sha1"
|
||||
|
||||
|
||||
Vendored
+9
-1
@@ -371,7 +371,15 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
|
||||
assert(newFile);
|
||||
|
||||
if (shouldDeleteThenExtract(originalInfo, newInfo)) {
|
||||
xar_prop_set(newFile, DELETE_THEN_EXTRACT_KEY, "true");
|
||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
||||
xar_prop_set(newFile, DELETE_KEY, "true");
|
||||
} else {
|
||||
xar_prop_set(newFile, DELETE_THEN_EXTRACT_OLD_KEY, "true");
|
||||
}
|
||||
}
|
||||
|
||||
if (MAJOR_VERSION_IS_AT_LEAST(majorVersion, SUBeigeMajorVersion)) {
|
||||
xar_prop_set(newFile, EXTRACT_KEY, "true");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user