diff --git a/Sparkle/SUBinaryDeltaTool.m b/Sparkle/SUBinaryDeltaTool.m index 81b80b28..29c8356a 100644 --- a/Sparkle/SUBinaryDeltaTool.m +++ b/Sparkle/SUBinaryDeltaTool.m @@ -240,7 +240,16 @@ int main(int __unused argc, char __unused *argv[]) NSOperationQueue *deltaQueue = [[NSOperationQueue alloc] init]; NSMutableArray *deltaOperations = [NSMutableArray array]; - NSArray *keys = [[newTreeState allKeys] sortedArrayUsingSelector:@selector(compare:)]; + // Sort the keys by preferring the ones from the original tree to appear first + // We want to enforce deleting before extracting in the case paths differ only by case + NSArray *keys = [[newTreeState allKeys] sortedArrayUsingComparator:^NSComparisonResult(NSString *key1, NSString *key2) { + NSComparisonResult insensitiveCompareResult = [key1 caseInsensitiveCompare:key2]; + if (insensitiveCompareResult != NSOrderedSame) { + return insensitiveCompareResult; + } + + return originalTreeState[key1] ? NSOrderedAscending : NSOrderedDescending; + }]; for (NSString* key in keys) { id value = [newTreeState valueForKey:key];