From e978cb0a3acbeb8458ba716964a30a16b52ca54f Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 19 Apr 2015 17:29:51 -0400 Subject: [PATCH] Update BinaryDelta formatting for creating/applying logs --- Sparkle/SUBinaryDeltaApply.m | 12 ++++++------ Sparkle/SUBinaryDeltaCommon.h | 8 ++++++++ Sparkle/SUBinaryDeltaCreate.m | 12 ++++++------ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Sparkle/SUBinaryDeltaApply.m b/Sparkle/SUBinaryDeltaApply.m index e69ad108..1e61cd0a 100644 --- a/Sparkle/SUBinaryDeltaApply.m +++ b/Sparkle/SUBinaryDeltaApply.m @@ -153,7 +153,7 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil } if (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_KEY, &value)) { if (verbose) { - fprintf(stderr, "\n❌ %s (Removed)", [path fileSystemRepresentation]); + fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [path fileSystemRepresentation]); } continue; } @@ -168,7 +168,7 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil } if (verbose) { - fprintf(stderr, "\n🔨 %s (Delta)", [path fileSystemRepresentation]); + fprintf(stderr, "\n🔨 %s %s", VERBOSE_PATCHED, [path fileSystemRepresentation]); } } 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 @@ -180,13 +180,13 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil if (verbose) { if (fileExisted) { - fprintf(stderr, "\n✏️ %s (Replaced)", [path fileSystemRepresentation]); + fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [path fileSystemRepresentation]); } else { - fprintf(stderr, "\n✅ %s (Added)", [path fileSystemRepresentation]); + fprintf(stderr, "\n✅ %s %s", VERBOSE_ADDED, [path fileSystemRepresentation]); } } } else if (verbose && removedFile) { - fprintf(stderr, "\n❌ %s (Removed)", [path fileSystemRepresentation]); + fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [path fileSystemRepresentation]); } if (!xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value)) { @@ -197,7 +197,7 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil } if (verbose) { - fprintf(stderr, "\n👮 %s (Mode: 0%o)", [path fileSystemRepresentation], mode); + fprintf(stderr, "\n👮 %s %s (0%o)", VERBOSE_MODIFIED, [path fileSystemRepresentation], mode); } } } diff --git a/Sparkle/SUBinaryDeltaCommon.h b/Sparkle/SUBinaryDeltaCommon.h index 803dbc3d..44a5d04e 100644 --- a/Sparkle/SUBinaryDeltaCommon.h +++ b/Sparkle/SUBinaryDeltaCommon.h @@ -31,6 +31,14 @@ #define BEFORE_TREE_SHA1_OLD_KEY "before-sha1" #define AFTER_TREE_SHA1_OLD_KEY "after-sha1" +#define VERBOSE_DELETED "Deleted" // file is deleted from the file system when applying a patch +#define VERBOSE_REMOVED "Removed" // file is set to be removed when creating a patch +#define VERBOSE_ADDED "Added" // file is added to the patch or file system +#define VERBOSE_DIFFED "Diffed" // file is diffed when creating a patch +#define VERBOSE_PATCHED "Patched" // file is patched when applying a patch +#define VERBOSE_UPDATED "Updated" // file's contents are updated +#define VERBOSE_MODIFIED "Modified" // file's metadata is modified + #define MAJOR_VERSION_IS_AT_LEAST(actualMajor, expectedMajor) (actualMajor >= expectedMajor) // Each major version will be assigned a name of a color diff --git a/Sparkle/SUBinaryDeltaCreate.m b/Sparkle/SUBinaryDeltaCreate.m index 5e2f0429..bd10e94d 100644 --- a/Sparkle/SUBinaryDeltaCreate.m +++ b/Sparkle/SUBinaryDeltaCreate.m @@ -367,7 +367,7 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi xar_prop_set(newFile, DELETE_KEY, "true"); if (verbose) { - fprintf(stderr, "\n❌ %s (Removed)", [key fileSystemRepresentation]); + fprintf(stderr, "\n❌ %s %s", VERBOSE_REMOVED, [key fileSystemRepresentation]); } continue; } @@ -382,7 +382,7 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]] UTF8String]); if (verbose) { - fprintf(stderr, "\n👮 %s (Mode: 0%o -> 0%o)", [key fileSystemRepresentation], [originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue], [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]); + fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [key fileSystemRepresentation], [originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue], [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]); } } } else { @@ -404,9 +404,9 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi if (verbose) { if (originalInfo) { - fprintf(stderr, "\n✏️ %s (Replaced)", [key fileSystemRepresentation]); + fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [key fileSystemRepresentation]); } else { - fprintf(stderr, "\n✅ %s (Added)", [key fileSystemRepresentation]); + fprintf(stderr, "\n✅ %s (%s)", VERBOSE_ADDED, [key fileSystemRepresentation]); } } } @@ -431,7 +431,7 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi } if (verbose) { - fprintf(stderr, "\n🔨 %s (Delta)", [[operation relativePath] fileSystemRepresentation]); + fprintf(stderr, "\n🔨 %s %s", VERBOSE_DIFFED, [[operation relativePath] fileSystemRepresentation]); } xar_file_t newFile = xar_add_frompath(x, 0, [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]); @@ -443,7 +443,7 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [operation.permissions unsignedShortValue]] UTF8String]); if (verbose) { - fprintf(stderr, "\n👮 %s (Mode: 0%o -> 0%o)", [[operation relativePath] fileSystemRepresentation], operation.oldPermissions.unsignedShortValue, operation.permissions.unsignedShortValue); + fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [[operation relativePath] fileSystemRepresentation], operation.oldPermissions.unsignedShortValue, operation.permissions.unsignedShortValue); } } }